Fix next page state

This commit is contained in:
Thomas Ricouard 2023-02-04 20:37:22 +01:00
parent 65ed2d871c
commit e96c1c5da7

View file

@ -174,13 +174,13 @@ extension TimelineViewModel: StatusesFetcher {
index > 0 index > 0
{ {
// Restore cache and scroll to latest seen status. // Restore cache and scroll to latest seen status.
statusesState = .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage) statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
scrollToIndexAnimated = false scrollToIndexAnimated = false
scrollToIndex = index + 1 scrollToIndex = index + 1
} else { } else {
// Restore cache and scroll to top. // Restore cache and scroll to top.
withAnimation { withAnimation {
statusesState = .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage) statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
} }
} }
// And then we fetch statuses again toget newest statuses from there. // And then we fetch statuses again toget newest statuses from there.
@ -308,7 +308,7 @@ extension TimelineViewModel: StatusesFetcher {
statuses.append(contentsOf: newStatuses) statuses.append(contentsOf: newStatuses)
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage) statusesState = .display(statuses: statuses, nextPageState: newStatuses.count < 20 ? .none : .hasNextPage)
} catch { } catch {
statusesState = .error(error: error) statusesState = .error(error: error)
} }