mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-18 07:11:58 +03:00
Always allow users sign out
- Updates the dialog with a more helpful error message for the user, letting them know what happens if they logout without informing the homeserver.
This commit is contained in:
parent
df1641995e
commit
cee6ec5939
3 changed files with 19 additions and 8 deletions
1
changelog.d/4855.bugfix
Normal file
1
changelog.d/4855.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix: Allow users to sign out even if the sign out request fails.
|
|
@ -328,6 +328,9 @@
|
|||
<string name="backup">Back up</string>
|
||||
<string name="sign_out_bottom_sheet_will_lose_secure_messages">You’ll lose access to your encrypted messages unless you back up your keys before signing out.</string>
|
||||
|
||||
<string name="sign_out_failed_dialog_message">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.</string>
|
||||
<string name="sign_out_anyway">Sign out anyway</string>
|
||||
|
||||
<!-- splash screen accessibility -->
|
||||
<string name="loading">Loading…</string>
|
||||
|
||||
|
|
|
@ -252,13 +252,10 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), 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<ActivityMainBinding>(), 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<ActivityMainBinding>(), 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()
|
||||
|
|
Loading…
Reference in a new issue