[WIP] Bot previews

This commit is contained in:
Isaac
2024-07-16 19:12:26 +08:00
parent 692931b27b
commit a4b4bb5a82
61 changed files with 1321 additions and 465 deletions

View File

@@ -2047,5 +2047,33 @@ public extension TelegramEngine.EngineData.Item {
}
}
}
public struct BotPreview: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
public typealias Result = CachedUserData.BotPreview?
fileprivate var id: EnginePeer.Id
public var mapKey: EnginePeer.Id {
return self.id
}
public init(id: EnginePeer.Id) {
self.id = id
}
var key: PostboxViewKey {
return .cachedPeerData(peerId: self.id)
}
func extract(view: PostboxView) -> Result {
guard let view = view as? CachedPeerDataView else {
preconditionFailure()
}
if let cachedData = view.cachedPeerData as? CachedUserData {
return cachedData.botPreview
} else {
return nil
}
}
}
}
}