mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
30 lines
870 B
Swift
30 lines
870 B
Swift
import SwiftSignalKit
|
|
import Postbox
|
|
|
|
public extension TelegramEngine.EngineData.Item {
|
|
enum ItemCache {
|
|
public struct Item: TelegramEngineDataItem, PostboxViewDataItem {
|
|
public typealias Result = CodableEntry?
|
|
|
|
private let collectionId: Int8
|
|
private let id: ValueBoxKey
|
|
|
|
public init(collectionId: Int8, id: ValueBoxKey) {
|
|
self.collectionId = collectionId
|
|
self.id = id
|
|
}
|
|
|
|
var key: PostboxViewKey {
|
|
return .cachedItem(ItemCacheEntryId(collectionId: collectionId, key: self.id))
|
|
}
|
|
|
|
func extract(view: PostboxView) -> Result {
|
|
guard let view = view as? CachedItemView else {
|
|
preconditionFailure()
|
|
}
|
|
return view.value
|
|
}
|
|
}
|
|
}
|
|
}
|