From acb0e38b8829a39914891df681a2c8b217f91ca2 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 15 Jan 2023 15:21:42 +0100 Subject: [PATCH] fix crash in AccountListFragment when network calls are cancelled (#3175) --- .../tusky/fragment/AccountListFragment.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.kt index 62535baa..9fa321d3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.kt @@ -134,7 +134,7 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct } override fun onMute(mute: Boolean, id: String, position: Int, notifications: Boolean) { - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { try { if (!mute) { api.unmuteAccount(id) @@ -180,7 +180,7 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct } override fun onBlock(block: Boolean, id: String, position: Int) { - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { try { if (!block) { api.unblockAccount(id) @@ -290,7 +290,7 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct binding.recyclerView.post { adapter.setBottomLoading(true) } } - lifecycleScope.launch { + viewLifecycleOwner.lifecycleScope.launch { try { val response = getFetchCallByListType(fromId) if (!response.isSuccessful) { @@ -307,8 +307,8 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct val linkHeader = response.headers()["Link"] onFetchAccountsSuccess(accountList, linkHeader) - } catch (throwable: Throwable) { - onFetchAccountsFailure(throwable) + } catch (exception: IOException) { + onFetchAccountsFailure(exception) } } }