Fix interminable room directory search next page loading loops when results don't fill the screen

This commit is contained in:
Stefan Ceriu 2024-06-17 21:32:32 +03:00 committed by Stefan Ceriu
parent dc9eb868d6
commit 261cb366a7
2 changed files with 9 additions and 7 deletions

View File

@ -104,6 +104,10 @@ class RoomDirectorySearchScreenViewModel: RoomDirectorySearchScreenViewModelType
}
private func loadNextPage() {
guard !state.isLoading else {
return
}
Task {
state.isLoading = true
let _ = await roomDirectorySearchProxy.nextPage()

View File

@ -40,14 +40,12 @@ struct RoomDirectorySearchScreen: View {
.foregroundColor(.compound.textSecondary)
.frame(maxWidth: .infinity)
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.searchNoResults)
} else {
// This needs to be in the else as when you start a search, the results are cleared making the footer visible.
// We only want to trigger the pagination when the state is not loading.
emptyRectangle
.onAppear {
context.send(viewAction: .reachedBottom)
}
}
emptyRectangle
.onAppear {
context.send(viewAction: .reachedBottom)
}
}
.listRowSeparator(.hidden)
}