mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
36 lines
1021 B
Swift
36 lines
1021 B
Swift
import Foundation
|
|
|
|
final class MutableCachedItemView: MutablePostboxView {
|
|
private let id: ItemCacheEntryId
|
|
fileprivate var value: CodableEntry?
|
|
|
|
init(postbox: PostboxImpl, id: ItemCacheEntryId) {
|
|
self.id = id
|
|
self.value = postbox.itemCacheTable.retrieve(id: id, metaTable: postbox.itemCacheMetaTable)
|
|
}
|
|
|
|
func replay(postbox: PostboxImpl, transaction: PostboxTransaction) -> Bool {
|
|
if transaction.updatedCacheEntryKeys.contains(self.id) {
|
|
self.value = postbox.itemCacheTable.retrieve(id: id, metaTable: postbox.itemCacheMetaTable)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func refreshDueToExternalTransaction(postbox: PostboxImpl) -> Bool {
|
|
return false
|
|
}
|
|
|
|
func immutableView() -> PostboxView {
|
|
return CachedItemView(self)
|
|
}
|
|
}
|
|
|
|
public final class CachedItemView: PostboxView {
|
|
public let value: CodableEntry?
|
|
|
|
init(_ view: MutableCachedItemView) {
|
|
self.value = view.value
|
|
}
|
|
}
|