fix: Prevent crash on "hidden domains" page (#703)

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
This commit is contained in:
Miles Krell 2024-05-30 13:35:39 -04:00 committed by GitHub
parent ab08974fc9
commit 5610cd23fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 10 deletions

View File

@ -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)
}
}
}

View File

@ -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>