mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Fix poll results cache consistency
This commit is contained in:
parent
305f2802c8
commit
53bf42bffc
@ -196,7 +196,7 @@ private final class PollResultsOptionContext {
|
|||||||
self.count = count
|
self.count = count
|
||||||
|
|
||||||
self.isLoadingMore = true
|
self.isLoadingMore = true
|
||||||
self.disposable.set((account.postbox.transaction { transaction -> [RenderedPeer]? in
|
self.disposable.set((account.postbox.transaction { transaction -> (peers: [RenderedPeer], canLoadMore: Bool)? in
|
||||||
let cachedResult = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPollResults, key: CachedPollOptionResult.key(pollId: pollId, optionOpaqueIdentifier: opaqueIdentifier))) as? CachedPollOptionResult
|
let cachedResult = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPollResults, key: CachedPollOptionResult.key(pollId: pollId, optionOpaqueIdentifier: opaqueIdentifier))) as? CachedPollOptionResult
|
||||||
if let cachedResult = cachedResult, Int(cachedResult.count) == count {
|
if let cachedResult = cachedResult, Int(cachedResult.count) == count {
|
||||||
var result: [RenderedPeer] = []
|
var result: [RenderedPeer] = []
|
||||||
@ -207,19 +207,20 @@ private final class PollResultsOptionContext {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return (result, Int(cachedResult.count) > result.count)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> deliverOn(self.queue)).start(next: { [weak self] cachedPeers in
|
|> deliverOn(self.queue)).start(next: { [weak self] cachedPeersAndCanLoadMore in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.isLoadingMore = false
|
strongSelf.isLoadingMore = false
|
||||||
if let cachedPeers = cachedPeers {
|
if let (cachedPeers, canLoadMore) = cachedPeersAndCanLoadMore {
|
||||||
strongSelf.results = cachedPeers
|
strongSelf.results = cachedPeers
|
||||||
strongSelf.hasLoadedOnce = true
|
strongSelf.hasLoadedOnce = true
|
||||||
|
strongSelf.canLoadMore = canLoadMore
|
||||||
}
|
}
|
||||||
strongSelf.loadMore()
|
strongSelf.loadMore()
|
||||||
}))
|
}))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user