mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Refactoring
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
|
||||
public final class EngineContactList {
|
||||
public let peers: [EnginePeer]
|
||||
public let presences: [EnginePeer.Id: EnginePeer.Presence]
|
||||
|
||||
public init(peers: [EnginePeer], presences: [EnginePeer.Id: EnginePeer.Presence]) {
|
||||
self.peers = peers
|
||||
self.presences = presences
|
||||
}
|
||||
}
|
||||
|
||||
public extension TelegramEngine.EngineData.Item {
|
||||
enum Contacts {
|
||||
public struct List: TelegramEngineDataItem, PostboxViewDataItem {
|
||||
public typealias Result = EngineContactList
|
||||
|
||||
private let includePresences: Bool
|
||||
|
||||
public init(includePresences: Bool) {
|
||||
self.includePresences = includePresences
|
||||
}
|
||||
|
||||
var key: PostboxViewKey {
|
||||
return .contacts(accountPeerId: nil, includePresences: self.includePresences)
|
||||
}
|
||||
|
||||
func extract(view: PostboxView) -> Result {
|
||||
guard let view = view as? ContactPeersView else {
|
||||
preconditionFailure()
|
||||
}
|
||||
return EngineContactList(peers: view.peers.map(EnginePeer.init), presences: view.peerPresences.mapValues(EnginePeer.Presence.init))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user