mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-18 19:40:19 +00:00
42 lines
1.3 KiB
Swift
42 lines
1.3 KiB
Swift
import Foundation
|
|
|
|
public enum PostboxViewKey: Hashable {
|
|
case itemCollectionInfos(namespaces: [ItemCollectionId.Namespace])
|
|
case peerChatState(peerId: PeerId)
|
|
|
|
public var hashValue: Int {
|
|
switch self {
|
|
case .itemCollectionInfos:
|
|
return 0
|
|
case let .peerChatState(peerId):
|
|
return peerId.hashValue
|
|
}
|
|
}
|
|
|
|
public static func ==(lhs: PostboxViewKey, rhs: PostboxViewKey) -> Bool {
|
|
switch lhs {
|
|
case let .itemCollectionInfos(lhsNamespaces):
|
|
if case let .itemCollectionInfos(rhsNamespaces) = rhs, lhsNamespaces == rhsNamespaces {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
case let .peerChatState(peerId):
|
|
if case .peerChatState(peerId) = rhs {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func postboxViewForKey(postbox: Postbox, key: PostboxViewKey) -> MutablePostboxView {
|
|
switch key {
|
|
case let .itemCollectionInfos(namespaces):
|
|
return MutableItemCollectionInfosView(postbox: postbox, namespaces: namespaces)
|
|
case let .peerChatState(peerId):
|
|
return MutablePeerChatStateView(postbox: postbox, peerId: peerId)
|
|
}
|
|
}
|