Make the code a bit easier to understand (no change)

This commit is contained in:
Benoit Marty 2021-02-18 18:42:55 +01:00
parent 73e93e7d3d
commit 2df9b43abc
2 changed files with 12 additions and 5 deletions

View File

@ -14,6 +14,7 @@ Bugfix 🐛:
- VoIP : fix audio devices output
- Fix crash after initial sync on Dendrite
- Fix crash reported by PlayStore (#2707)
- Fix crash when deactivating an account
Translations 🗣:
-

View File

@ -45,10 +45,11 @@ internal class DefaultDeactivateAccountTask @Inject constructor(
override suspend fun execute(params: DeactivateAccountTask.Params) {
val deactivateAccountParams = DeactivateAccountParams.create(params.userAuthParam, params.eraseAllData)
try {
val canCleanup = try {
executeRequest<Unit>(globalErrorReceiver) {
apiCall = accountAPI.deactivate(deactivateAccountParams)
}
true
} catch (throwable: Throwable) {
if (!handleUIA(
failure = throwable,
@ -60,12 +61,17 @@ internal class DefaultDeactivateAccountTask @Inject constructor(
) {
Timber.d("## UIA: propagate failure")
throw throwable
} else {
false
}
}
// Logout from identity server if any, ignoring errors
runCatching { identityDisconnectTask.execute(Unit) }
.onFailure { Timber.w(it, "Unable to disconnect identity server") }
cleanupSession.handle()
if (canCleanup) {
// Logout from identity server if any, ignoring errors
runCatching { identityDisconnectTask.execute(Unit) }
.onFailure { Timber.w(it, "Unable to disconnect identity server") }
cleanupSession.handle()
}
}
}