Maybe fix race condition between iCloud sync and state restoration
This commit is contained in:
parent
5029b26b40
commit
68682ee291
|
@ -364,6 +364,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
]
|
||||
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||
}()
|
||||
let originalPositionStatusIDs = position.statusIDs
|
||||
|
||||
let unloaded = position.statusIDs.filter({ mastodonController.persistentContainer.status(for: $0) == nil })
|
||||
guard !unloaded.isEmpty else {
|
||||
return true
|
||||
|
@ -420,6 +422,14 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||
}()
|
||||
|
||||
// if an icloud sync completed in between starting to load the statuses and finishing, try to load again
|
||||
if position.statusIDs != originalPositionStatusIDs {
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
crumb.message = "TimelinePosition statusIDs changed, retrying load"
|
||||
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||
return await loadStatusesToRestore(position: position)
|
||||
}
|
||||
|
||||
// update the timeline position in case some statuses couldn't be loaded
|
||||
if let center = position.centerStatusID {
|
||||
let nearestLoadedStatusToCenter = position.statusIDs[position.statusIDs.firstIndex(of: center)!...].first(where: { id in
|
||||
|
|
Loading…
Reference in New Issue