diff --git a/Tusker/Screens/Bookmarks/BookmarksViewController.swift b/Tusker/Screens/Bookmarks/BookmarksViewController.swift index 76e8c06c..cd77c8a0 100644 --- a/Tusker/Screens/Bookmarks/BookmarksViewController.swift +++ b/Tusker/Screens/Bookmarks/BookmarksViewController.swift @@ -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 { 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