Fix race condition loading bookmarks
This commit is contained in:
parent
f2a8b91769
commit
c7b4d00da7
|
@ -45,7 +45,7 @@ class BookmarksTableViewController: EnhancedTableViewController {
|
|||
let request = Client.getBookmarks()
|
||||
mastodonController.run(request) { (response) in
|
||||
guard case let .success(statuses, pagination) = response else { fatalError() }
|
||||
self.mastodonController.persistentContainer.addAll(statuses: statuses)
|
||||
self.mastodonController.persistentContainer.addAll(statuses: statuses) {
|
||||
self.statuses.append(contentsOf: statuses.map { ($0.id, .unknown) })
|
||||
self.newer = pagination?.newer
|
||||
self.older = pagination?.older
|
||||
|
@ -54,6 +54,7 @@ class BookmarksTableViewController: EnhancedTableViewController {
|
|||
self.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
userActivity = UserActivityManager.bookmarksActivity()
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ class BookmarksTableViewController: EnhancedTableViewController {
|
|||
mastodonController.run(request) { (response) in
|
||||
guard case let .success(newStatuses, pagination) = response else { fatalError() }
|
||||
self.older = pagination?.older
|
||||
self.mastodonController.persistentContainer.addAll(statuses: newStatuses)
|
||||
self.mastodonController.persistentContainer.addAll(statuses: newStatuses) {
|
||||
let newIndexPaths = (self.statuses.count..<(self.statuses.count + newStatuses.count)).map {
|
||||
IndexPath(row: $0, section: 0)
|
||||
}
|
||||
|
@ -100,6 +101,7 @@ class BookmarksTableViewController: EnhancedTableViewController {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue