mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Filter duplicate group ids
This commit is contained in:
@@ -78,6 +78,7 @@ func chatHistoryEntriesForView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var existingGroupStableIds: [UInt32] = []
|
||||||
var groupBucket: [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, MessageHistoryEntryLocation?)] = []
|
var groupBucket: [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, MessageHistoryEntryLocation?)] = []
|
||||||
var count = 0
|
var count = 0
|
||||||
loop: for entry in view.entries {
|
loop: for entry in view.entries {
|
||||||
@@ -156,7 +157,11 @@ func chatHistoryEntriesForView(
|
|||||||
|
|
||||||
if groupMessages {
|
if groupMessages {
|
||||||
if !groupBucket.isEmpty && message.groupInfo != groupBucket[0].0.groupInfo {
|
if !groupBucket.isEmpty && message.groupInfo != groupBucket[0].0.groupInfo {
|
||||||
|
let groupStableId = groupBucket[0].0.groupInfo!.stableId
|
||||||
|
if !existingGroupStableIds.contains(groupStableId) {
|
||||||
|
existingGroupStableIds.append(groupStableId)
|
||||||
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
|
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
|
||||||
|
}
|
||||||
groupBucket.removeAll()
|
groupBucket.removeAll()
|
||||||
}
|
}
|
||||||
if let _ = message.groupInfo {
|
if let _ = message.groupInfo {
|
||||||
@@ -189,9 +194,16 @@ func chatHistoryEntriesForView(
|
|||||||
|
|
||||||
if !groupBucket.isEmpty {
|
if !groupBucket.isEmpty {
|
||||||
assert(groupMessages)
|
assert(groupMessages)
|
||||||
|
|
||||||
|
let groupStableId = groupBucket[0].0.groupInfo!.stableId
|
||||||
|
if !existingGroupStableIds.contains(groupStableId) {
|
||||||
|
existingGroupStableIds.append(groupStableId)
|
||||||
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
|
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
groupBucket.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
if let maybeJoinMessage = joinMessage, !view.holeLater {
|
if let maybeJoinMessage = joinMessage, !view.holeLater {
|
||||||
entries.append(.MessageEntry(maybeJoinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false, isCentered: false)))
|
entries.append(.MessageEntry(maybeJoinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false, isCentered: false)))
|
||||||
joinMessage = nil
|
joinMessage = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user