diff --git a/changelog.d/4855.bugfix b/changelog.d/4855.bugfix new file mode 100644 index 0000000000..d85feb42e7 --- /dev/null +++ b/changelog.d/4855.bugfix @@ -0,0 +1 @@ +Fix: Allow users to sign out even if the sign out request fails. diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 3d1a36d4c3..ddd333017e 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -328,6 +328,9 @@ Back up You’ll lose access to your encrypted messages unless you back up your keys before signing out. + Cannot reach the homeserver. If you sign out anyway, this device will not be erased from your device list, you may want to remove it using another client. + Sign out anyway + Loading… diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt index cffb1577cf..676986d0df 100644 --- a/vector/src/main/java/im/vector/app/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt @@ -252,13 +252,10 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity try { session.signOutService().signOut(!args.isUserLoggedOut) } catch (failure: Throwable) { - displayError(failure) + displaySignOutFailedDialog(onboardingStore) return@launch } - Timber.w("SIGN_OUT: success, start app") - activeSessionHolder.clearActiveSession() - doLocalCleanup(clearPreferences = true, onboardingStore) - startNextActivityAndFinish() + completeSignout(onboardingStore) } } args.clearCache -> { @@ -272,6 +269,15 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity } } + private fun completeSignout(onboardingStore: VectorSessionStore) { + lifecycleScope.launch { + Timber.w("SIGN_OUT: success, start app") + activeSessionHolder.clearActiveSession() + doLocalCleanup(clearPreferences = true, onboardingStore) + startNextActivityAndFinish() + } + } + override fun handleInvalidToken(globalError: GlobalError.InvalidToken) { // No op here Timber.w("Ignoring invalid token global error") @@ -299,12 +305,13 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity } } - private fun displayError(failure: Throwable) { + private fun displaySignOutFailedDialog(onboardingStore: VectorSessionStore) { if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) { MaterialAlertDialogBuilder(this) .setTitle(R.string.dialog_title_error) - .setMessage(errorFormatter.toHumanReadable(failure)) - .setPositiveButton(R.string.global_retry) { _, _ -> doCleanUp() } + .setMessage(R.string.sign_out_failed_dialog_message) + .setPositiveButton(R.string.sign_out_anyway) { _, _ -> completeSignout(onboardingStore) } + .setNeutralButton(R.string.global_retry) { _, _ -> doCleanUp() } .setNegativeButton(R.string.action_cancel) { _, _ -> startNextActivityAndFinish(ignoreClearCredentials = true) } .setCancelable(false) .show()