Fix inserting pinned items that already exist when refreshing profile
This commit is contained in:
parent
84cf755332
commit
999118798c
|
@ -222,7 +222,17 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
}
|
||||
|
||||
var snapshot = dataSource.snapshot()
|
||||
let items = statuses.map { Item.status(id: $0.id, state: .unknown, pinned: true) }
|
||||
let existingPinned = snapshot.itemIdentifiers(inSection: .pinned)
|
||||
let items = statuses.map {
|
||||
let item = Item.status(id: $0.id, state: .unknown, pinned: true)
|
||||
// try to keep the existing status state
|
||||
if let existing = existingPinned.first(where: { $0 == item }) {
|
||||
return existing
|
||||
} else {
|
||||
return item
|
||||
}
|
||||
}
|
||||
snapshot.deleteItems(snapshot.itemIdentifiers(inSection: .pinned))
|
||||
snapshot.appendItems(items, toSection: .pinned)
|
||||
await apply(snapshot, animatingDifferences: true)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue