mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Always request folder updates after restart
This commit is contained in:
parent
0912b07b8f
commit
3076a576dd
@ -448,12 +448,21 @@ public final class ChatFolderUpdates: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
private struct FirstTimeFolderUpdatesKey: Hashable {
|
||||
var accountId: AccountRecordId
|
||||
var folderId: Int32
|
||||
}
|
||||
private var firstTimeFolderUpdates = Set<FirstTimeFolderUpdatesKey>()
|
||||
|
||||
func _internal_pollChatFolderUpdatesOnce(account: Account, folderId: Int32) -> Signal<Never, NoError> {
|
||||
return account.postbox.transaction { transaction -> ChatListFiltersState in
|
||||
return _internal_currentChatListFiltersState(transaction: transaction)
|
||||
}
|
||||
|> mapToSignal { state -> Signal<Never, NoError> in
|
||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
let key = FirstTimeFolderUpdatesKey(accountId: account.id, folderId: folderId)
|
||||
|
||||
if firstTimeFolderUpdates.contains(key) {
|
||||
if let current = state.updates.first(where: { $0.folderId == folderId }) {
|
||||
let updateInterval: Int32
|
||||
#if DEBUG
|
||||
@ -463,9 +472,13 @@ func _internal_pollChatFolderUpdatesOnce(account: Account, folderId: Int32) -> S
|
||||
#endif
|
||||
|
||||
if current.timestamp + updateInterval >= timestamp {
|
||||
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
firstTimeFolderUpdates.insert(key)
|
||||
}
|
||||
|
||||
return account.network.request(Api.functions.communities.getCommunityUpdates(community: .inputCommunityDialogFilter(filterId: folderId)))
|
||||
|> map(Optional.init)
|
||||
|
Loading…
x
Reference in New Issue
Block a user