mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Fix message index ordering
This commit is contained in:
@@ -242,11 +242,13 @@ private final class ChatListViewSpaceState {
|
||||
let allIndices = (lowerOrAtAnchorMessages + higherThanAnchorMessages).map { $0.entryIndex }
|
||||
let allEntityIds = (lowerOrAtAnchorMessages + higherThanAnchorMessages).map { $0.entityId }
|
||||
if Set(allIndices).count != allIndices.count {
|
||||
var debugRepeatedIndices = Set<MutableChatListEntryIndex>()
|
||||
var existingIndices = Set<MutableChatListEntryIndex>()
|
||||
for i in (0 ..< lowerOrAtAnchorMessages.count).reversed() {
|
||||
if !existingIndices.contains(lowerOrAtAnchorMessages[i].entryIndex) {
|
||||
existingIndices.insert(lowerOrAtAnchorMessages[i].entryIndex)
|
||||
} else {
|
||||
debugRepeatedIndices.insert(lowerOrAtAnchorMessages[i].entryIndex)
|
||||
lowerOrAtAnchorMessages.remove(at: i)
|
||||
}
|
||||
}
|
||||
@@ -254,10 +256,11 @@ private final class ChatListViewSpaceState {
|
||||
if !existingIndices.contains(higherThanAnchorMessages[i].entryIndex) {
|
||||
existingIndices.insert(higherThanAnchorMessages[i].entryIndex)
|
||||
} else {
|
||||
debugRepeatedIndices.insert(higherThanAnchorMessages[i].entryIndex)
|
||||
higherThanAnchorMessages.remove(at: i)
|
||||
}
|
||||
}
|
||||
postboxLog("allIndices not unique: \(allIndices)")
|
||||
postboxLog("allIndices not unique, repeated: \(debugRepeatedIndices)")
|
||||
|
||||
assert(false)
|
||||
//preconditionFailure()
|
||||
|
||||
Reference in New Issue
Block a user