fix crash in AccountListFragment when network calls are cancelled (#3175)

This commit is contained in:
Konrad Pozniak 2023-01-15 15:21:42 +01:00 committed by GitHub
parent 8058c4bc79
commit acb0e38b88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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