diff --git a/submodules/TelegramCore/Sources/State/AccountViewTracker.swift b/submodules/TelegramCore/Sources/State/AccountViewTracker.swift index 3f6babaeae..bbc867eb29 100644 --- a/submodules/TelegramCore/Sources/State/AccountViewTracker.swift +++ b/submodules/TelegramCore/Sources/State/AccountViewTracker.swift @@ -330,14 +330,14 @@ public final class AccountViewTracker { private let externallyUpdatedPeerIdDisposable = MetaDisposable() - public let chatListPreloadItems = Promise<[ChatHistoryPreloadItem]>([]) + public let chatListPreloadItems = Promise>([]) init(account: Account) { self.account = account self.historyViewStateValidationContexts = HistoryViewStateValidationContexts(queue: self.queue, postbox: account.postbox, network: account.network, accountPeerId: account.peerId) - self.chatHistoryPreloadManager = ChatHistoryPreloadManager(postbox: account.postbox, network: account.network, accountPeerId: account.peerId, networkState: account.networkState, preloadItemsSignal: self.chatListPreloadItems.get() |> distinctUntilChanged) + self.chatHistoryPreloadManager = ChatHistoryPreloadManager(postbox: account.postbox, network: account.network, accountPeerId: account.peerId, networkState: account.networkState, preloadItemsSignal: self.chatListPreloadItems.get() |> distinctUntilChanged |> map { Array($0) }) self.externallyUpdatedPeerIdDisposable.set((account.stateManager.externallyUpdatedPeerIds |> deliverOn(self.queue)).start(next: { [weak self] peerIds in diff --git a/submodules/TelegramCore/Sources/State/ChatHistoryPreloadManager.swift b/submodules/TelegramCore/Sources/State/ChatHistoryPreloadManager.swift index 8e91b7686f..11f588c64e 100644 --- a/submodules/TelegramCore/Sources/State/ChatHistoryPreloadManager.swift +++ b/submodules/TelegramCore/Sources/State/ChatHistoryPreloadManager.swift @@ -247,12 +247,19 @@ private final class AdditionalPreloadPeerIdsContext { } } -public struct ChatHistoryPreloadItem : Equatable { +public struct ChatHistoryPreloadItem : Equatable, Hashable { public let index: ChatListIndex public let threadId: Int64? public let isMuted: Bool public let hasUnread: Bool + public func hash(into hasher: inout Hasher) { + hasher.combine(index.hashValue) + if let threadId = threadId { + hasher.combine(threadId) + } + } + public init(index: ChatListIndex, threadId: Int64?, isMuted: Bool, hasUnread: Bool) { self.index = index self.threadId = threadId