Fix crash when tapping Load More button with Disable Infinite Scrolling

This commit is contained in:
Shadowfacts 2022-10-31 17:45:36 -04:00
parent 8da89986df
commit 6a5753fac8
1 changed files with 5 additions and 1 deletions

View File

@ -96,7 +96,11 @@ actor TimelineLikeController<Item> {
return
}
let token = LoadAttemptToken()
guard await delegate.canLoadOlder() else {
guard await delegate.canLoadOlder(),
// Make sure we're still in the idle state before continuing on, since that may have chnaged while waiting for user input.
// If the load more cell appears, then the users scrolls up and back down, the VC may kick off a second loadOlder task
// but we only want one to proceed. The actor prevents a data race, and this prevents multiple simultaneousl loadOlder tasks from running.
state == .idle else {
return
}
state = .loadingOlder(token, hasAddedLoadingIndicator: false)