mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Support refreshDueToExternalTransaction in more views
This commit is contained in:
@@ -29,6 +29,41 @@ final class MutableTopChatMessageView: MutablePostboxView {
|
||||
|
||||
return updated
|
||||
}
|
||||
|
||||
func refreshDueToExternalTransaction(postbox: PostboxImpl) -> Bool {
|
||||
var messages: [PeerId: Message] = [:]
|
||||
|
||||
for peerId in self.peerIds {
|
||||
if let index = postbox.chatListIndexTable.get(peerId: peerId).topMessageIndex {
|
||||
messages[peerId] = postbox.getMessage(index.id)
|
||||
}
|
||||
}
|
||||
|
||||
var updated = false
|
||||
|
||||
if self.messages.count != messages.count {
|
||||
updated = true
|
||||
} else {
|
||||
for (key, value) in self.messages {
|
||||
if let other = messages[key] {
|
||||
if other.stableId != value.stableId || other.stableVersion != value.stableVersion {
|
||||
updated = true
|
||||
break
|
||||
}
|
||||
} else {
|
||||
updated = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if updated {
|
||||
self.messages = messages
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func immutableView() -> PostboxView {
|
||||
return TopChatMessageView(self)
|
||||
|
||||
Reference in New Issue
Block a user