fix: Show/hide the list of lists appropriately when showing errors (#740)

Previous code didn't hide the list-of-lists if an error occurred after
the list was displayed (e.g., load the list, turn on airplane mode,
reload the list).

Hide the list when errors are shown, and show it when there is content.
This commit is contained in:
Nik Clayton 2024-06-11 22:18:51 +02:00 committed by GitHub
parent d0432dbd24
commit 7bf8c382e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -222,6 +222,7 @@ class ListsActivity : BaseActivity(), MenuProvider {
private fun bind(state: Result<Lists, ApiError>) {
state.onFailure {
binding.listsRecycler.hide()
binding.messageView.show()
binding.swipeRefreshLayout.isRefreshing = false
@ -238,9 +239,11 @@ class ListsActivity : BaseActivity(), MenuProvider {
adapter.submitList(lists.lists.sortedWith(compareByListTitle))
binding.swipeRefreshLayout.isRefreshing = false
if (lists.lists.isEmpty()) {
binding.listsRecycler.hide()
binding.messageView.show()
binding.messageView.setup(BackgroundMessage.Empty())
} else {
binding.listsRecycler.show()
binding.messageView.hide()
}
}