forked from shadowfacts/Tusker
Fix bookmarks VC sometimes going haywire
This commit is contained in:
parent
509acbde19
commit
ebfd8b3efd
|
@ -219,6 +219,11 @@ class BookmarksViewController: UIViewController, CollectionViewController, Refre
|
|||
}
|
||||
|
||||
@objc private func managedObjectsDidChange(_ notification: Foundation.Notification) {
|
||||
// only perform local updates while the vc is idle
|
||||
// otherwise loading the bookmarks ends up inserting them out of order
|
||||
guard case .loaded = state else {
|
||||
return
|
||||
}
|
||||
var snapshot = dataSource.snapshot()
|
||||
func prepend(item: Item) {
|
||||
if let first = snapshot.itemIdentifiers.first {
|
||||
|
@ -237,7 +242,7 @@ class BookmarksViewController: UIViewController, CollectionViewController, Refre
|
|||
if let updated = notification.userInfo?[NSUpdatedObjectsKey] as? Set<NSManagedObject> {
|
||||
for case let status as StatusMO in updated {
|
||||
let item = Item.status(id: status.id, state: .unknown, addedLocally: true)
|
||||
var exists = snapshot.itemIdentifiers.contains(item)
|
||||
let exists = snapshot.itemIdentifiers.contains(item)
|
||||
if status.bookmarked == true && !exists {
|
||||
prepend(item: item)
|
||||
hasChanges = true
|
||||
|
|
Loading…
Reference in New Issue