mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 05:26:48 +00:00
Update peers in message history views
This commit is contained in:
parent
bc09798555
commit
99a1a9392c
@ -683,6 +683,11 @@ final class MutableMessageHistoryView {
|
||||
hasChanges = true
|
||||
}
|
||||
}
|
||||
if !transaction.currentUpdatedPeers.isEmpty {
|
||||
if loadedState.updatePeers(postbox: postbox, updatedPeers: transaction.currentUpdatedPeers) {
|
||||
hasChanges = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if hasChanges {
|
||||
|
||||
@ -1514,6 +1514,43 @@ final class HistoryViewLoadedState {
|
||||
return updated
|
||||
}
|
||||
|
||||
func updatePeers(postbox: PostboxImpl, updatedPeers: [PeerId: Peer]) -> Bool {
|
||||
var updated = false
|
||||
for space in self.orderedEntriesBySpace.keys {
|
||||
let spaceUpdated = self.orderedEntriesBySpace[space]!.mutableScan({ entry in
|
||||
switch entry {
|
||||
case let .MessageEntry(value, reloadAssociatedMessages, reloadPeers):
|
||||
let message = value.message
|
||||
var rebuild = false
|
||||
var peers = message.peers
|
||||
var author = message.author
|
||||
for (peerId, _) in message.peers {
|
||||
if let updatedPeer = updatedPeers[peerId] {
|
||||
peers[peerId] = updatedPeer
|
||||
rebuild = true
|
||||
}
|
||||
}
|
||||
if let authorValue = author, let updatedAuthor = updatedPeers[authorValue.id] {
|
||||
author = updatedAuthor
|
||||
rebuild = true
|
||||
}
|
||||
|
||||
if rebuild {
|
||||
let updatedMessage = message.withUpdatedPeers(peers).withUpdatedAuthor(author)
|
||||
return .MessageEntry(MessageHistoryMessageEntry(message: updatedMessage, location: value.location, monthLocation: value.monthLocation, attributes: value.attributes), reloadAssociatedMessages: reloadAssociatedMessages, reloadPeers: reloadPeers)
|
||||
}
|
||||
case .IntermediateMessageEntry:
|
||||
break
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if spaceUpdated {
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
return updated
|
||||
}
|
||||
|
||||
func add(entry: MutableMessageHistoryEntry) -> Bool {
|
||||
if let ignoreMessagesInTimestampRange = self.ignoreMessagesInTimestampRange {
|
||||
if ignoreMessagesInTimestampRange.contains(entry.index.timestamp) {
|
||||
|
||||
@ -120,6 +120,18 @@ public enum ChatHistoryEntry: Identifiable, Comparable {
|
||||
if lhsMessage.stableVersion != rhsMessage.stableVersion {
|
||||
return false
|
||||
}
|
||||
|
||||
if lhsMessage.peers.count != rhsMessage.peers.count {
|
||||
return false
|
||||
}
|
||||
for (id, peer) in lhsMessage.peers {
|
||||
if let otherPeer = rhsMessage.peers[id] {
|
||||
if !peer.isEqual(otherPeer) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if lhsMessage.media.count != rhsMessage.media.count {
|
||||
return false
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user