mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Refactoring
This commit is contained in:
@@ -1,33 +1,11 @@
|
||||
import Foundation
|
||||
|
||||
public protocol MediaResourceId {
|
||||
var uniqueId: String { get }
|
||||
var hashValue: Int { get }
|
||||
func isEqual(to: MediaResourceId) -> Bool
|
||||
}
|
||||
public struct MediaResourceId: Equatable, Hashable {
|
||||
public var stringRepresentation: String
|
||||
|
||||
public struct WrappedMediaResourceId: Hashable {
|
||||
public let id: MediaResourceId
|
||||
|
||||
public init(_ id: MediaResourceId) {
|
||||
self.id = id
|
||||
public init(_ stringRepresentation: String) {
|
||||
self.stringRepresentation = stringRepresentation
|
||||
}
|
||||
|
||||
public static func ==(lhs: WrappedMediaResourceId, rhs: WrappedMediaResourceId) -> Bool {
|
||||
return lhs.id.isEqual(to: rhs.id)
|
||||
}
|
||||
|
||||
// public var hashValue: Int {
|
||||
// return self.id.hashValue
|
||||
// }
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(self.id.hashValue)
|
||||
}
|
||||
}
|
||||
|
||||
public func anyHashableFromMediaResourceId(_ id: MediaResourceId) -> AnyHashable {
|
||||
return AnyHashable(WrappedMediaResourceId(id))
|
||||
}
|
||||
|
||||
public protocol MediaResource {
|
||||
|
||||
Reference in New Issue
Block a user