Skip to content

Commit

Permalink
fix: Prevent crash on "hidden domains" page (#703)
Browse files Browse the repository at this point in the history
The crash was caused by an uncaught exception when calling
`MastodonApi#domainBlocks`.

Update the `BackgroundMessageView` for the error message so it fills the
screen like on other pages.

Fixes #696
  • Loading branch information
mileskrell authored May 30, 2024
1 parent ab08974 commit 5610cd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ class InstanceListFragment :
}

viewLifecycleOwner.lifecycleScope.launch {
val response = api.domainBlocks(id, bottomId)
val instances = response.body()

if (response.isSuccessful && instances != null) {
onFetchInstancesSuccess(instances, response.headers()["Link"])
} else {
onFetchInstancesFailure(Exception(response.message()))
try {
val response = api.domainBlocks(id, bottomId)
val instances = response.body()
if (response.isSuccessful && instances != null) {
onFetchInstancesSuccess(instances, response.headers()["Link"])
} else {
onFetchInstancesFailure(Exception(response.message()))
}
} catch (e: Exception) {
onFetchInstancesFailure(e)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/fragment_instance_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

<app.pachli.core.ui.BackgroundMessageView
android:id="@+id/messageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>

0 comments on commit 5610cd2

Please sign in to comment.