Filter duplicate group ids

This commit is contained in:
Ali
2023-03-09 09:21:39 +04:00
parent 579fa24c3e
commit e308512bfd

View File

@@ -77,7 +77,8 @@ func chatHistoryEntriesForView(
associatedThreadInfo: nil
)
}
var existingGroupStableIds: [UInt32] = []
var groupBucket: [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, MessageHistoryEntryLocation?)] = []
var count = 0
loop: for entry in view.entries {
@@ -156,7 +157,11 @@ func chatHistoryEntriesForView(
if groupMessages {
if !groupBucket.isEmpty && message.groupInfo != groupBucket[0].0.groupInfo {
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
let groupStableId = groupBucket[0].0.groupInfo!.stableId
if !existingGroupStableIds.contains(groupStableId) {
existingGroupStableIds.append(groupStableId)
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
}
groupBucket.removeAll()
}
if let _ = message.groupInfo {
@@ -189,7 +194,14 @@ func chatHistoryEntriesForView(
if !groupBucket.isEmpty {
assert(groupMessages)
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
let groupStableId = groupBucket[0].0.groupInfo!.stableId
if !existingGroupStableIds.contains(groupStableId) {
existingGroupStableIds.append(groupStableId)
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
}
groupBucket.removeAll()
}
if let maybeJoinMessage = joinMessage, !view.holeLater {