diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt index 72993311..95a61109 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt @@ -56,6 +56,7 @@ import com.keylesspalace.tusky.util.startActivityWithSlideInAnimation import com.keylesspalace.tusky.util.viewBinding import com.keylesspalace.tusky.view.EndlessOnScrollListener import javax.inject.Inject +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.launch import retrofit2.Response @@ -329,6 +330,12 @@ class AccountListFragment : val linkHeader = response.headers()["Link"] onFetchAccountsSuccess(accountList, linkHeader) } catch (exception: Exception) { + if (exception is CancellationException) { + // Scope is cancelled, probably because the fragment is destroyed. + // We must not touch any views anymore, so rethrow the exception. + // (CancellationException in a cancelled scope is normal and will be ignored) + throw exception + } onFetchAccountsFailure(exception) } }