mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Ensure that ordered item list keys are unique
This commit is contained in:
@@ -27,8 +27,20 @@ private func managedRecentMedia(postbox: Postbox, network: Network, collectionId
|
||||
itemIds.reverse()
|
||||
}
|
||||
return fetch(forceFetch ? 0 : hashForIds(itemIds))
|
||||
|> mapToSignal { items in
|
||||
if let items = items {
|
||||
|> mapToSignal { sourceItems in
|
||||
var items: [OrderedItemListEntry] = []
|
||||
if let sourceItems = sourceItems {
|
||||
var existingIds = Set<MediaId>()
|
||||
for item in sourceItems {
|
||||
guard let id = (item.contents as? RecentMediaItem)?.media.id else {
|
||||
continue
|
||||
}
|
||||
if !existingIds.contains(id) {
|
||||
existingIds.insert(id)
|
||||
items.append(item)
|
||||
}
|
||||
}
|
||||
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.replaceOrderedItemListItems(collectionId: collectionId, items: items)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user