mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-29 09:01:05 +00:00
Fix message group updates
This commit is contained in:
parent
23d5f5f84f
commit
f8ee1688fc
@ -205,11 +205,21 @@ func applyUpdateGroupMessages(postbox: Postbox, stateManager: AccountStateManage
|
||||
var sentGifs: [TelegramMediaFile] = []
|
||||
|
||||
var updatedGroupingKey: Int64?
|
||||
for (_, _, updatedMessage) in mapping {
|
||||
if let updatedGroupingKey = updatedGroupingKey {
|
||||
assert(updatedGroupingKey == updatedMessage.groupingKey)
|
||||
}
|
||||
updatedGroupingKey = updatedMessage.groupingKey
|
||||
}
|
||||
|
||||
if let latestPreviousId = latestPreviousId, let latestIndex = mapping.last?.1 {
|
||||
transaction.offsetPendingMessagesTimestamps(lowerBound: latestPreviousId, excludeIds: Set(mapping.map { $0.0.id }), timestamp: latestIndex.timestamp)
|
||||
}
|
||||
|
||||
if let updatedGroupingKey = updatedGroupingKey {
|
||||
transaction.updateMessageGroupingKeysAtomically(mapping.map { $0.0.id }, groupingKey: updatedGroupingKey)
|
||||
}
|
||||
|
||||
for (message, _, updatedMessage) in mapping {
|
||||
transaction.updateMessage(message.id, update: { currentMessage in
|
||||
let updatedId: MessageId
|
||||
@ -258,19 +268,10 @@ func applyUpdateGroupMessages(postbox: Postbox, stateManager: AccountStateManage
|
||||
|
||||
let (tags, globalTags) = tagsForStoreMessage(incoming: currentMessage.flags.contains(.Incoming), attributes: attributes, media: media, textEntities: entitiesAttribute?.entities)
|
||||
|
||||
if let updatedGroupingKey = updatedGroupingKey {
|
||||
assert(updatedGroupingKey == updatedMessage.groupingKey)
|
||||
}
|
||||
updatedGroupingKey = updatedMessage.groupingKey
|
||||
|
||||
return .update(StoreMessage(id: updatedId, globallyUniqueId: nil, groupingKey: currentMessage.groupingKey, timestamp: updatedMessage.timestamp, flags: [], tags: tags, globalTags: globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: text, attributes: attributes, media: media))
|
||||
})
|
||||
}
|
||||
|
||||
if let updatedGroupingKey = updatedGroupingKey {
|
||||
transaction.updateMessageGroupingKeysAtomically(mapping.map { $0.1.id }, groupingKey: updatedGroupingKey)
|
||||
}
|
||||
|
||||
for file in sentStickers {
|
||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user