Logout: do not double render the progress state and disable the cancel button during the process.

This commit is contained in:
Benoit Marty
2026-09-28 17:31:42 +02:00
parent 672b6eaf81
commit 26ea6be44c
3 changed files with 13 additions and 2 deletions
@@ -47,6 +47,9 @@ import io.element.android.libraries.testtags.TestTags
import io.element.android.libraries.testtags.testTag
import io.element.android.libraries.ui.strings.CommonStrings
/**
* Ref: https://www.figma.com/design/kEAcfun9iSpszeUDvdKZ6b/ER-351--Multi-account-in-EX?node-id=442-34581
*/
@Composable
fun LogoutView(
state: LogoutState,
@@ -78,6 +81,8 @@ fun LogoutView(
LogoutActionDialog(
state.logoutAction,
// Do not show the progress dialog, the progress is rendered in the button.
showProgressDialog = false,
onConfirmClick = {
eventSink(LogoutEvent.Logout(ignoreSdkError = false))
},
@@ -149,6 +154,7 @@ private fun ColumnScope.Buttons(
)
TextButton(
text = stringResource(id = CommonStrings.action_cancel),
enabled = logoutAction !is AsyncAction.Loading,
modifier = Modifier.fillMaxWidth(),
onClick = onCancelClick,
)
@@ -27,6 +27,7 @@ class DefaultDirectLogoutView : DirectLogoutView {
val eventSink = state.eventSink
LogoutActionDialog(
state.logoutAction,
showProgressDialog = true,
onConfirmClick = {
eventSink(DirectLogoutEvent.Logout(ignoreSdkError = false))
},
@@ -19,6 +19,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
@Composable
fun LogoutActionDialog(
state: AsyncAction<Unit>,
showProgressDialog: Boolean,
onConfirmClick: () -> Unit,
onForceLogoutClick: () -> Unit,
onDismissDialog: () -> Unit,
@@ -31,8 +32,11 @@ fun LogoutActionDialog(
onSubmitClick = onConfirmClick,
onDismiss = onDismissDialog
)
is AsyncAction.Loading ->
ProgressDialog(text = stringResource(id = R.string.screen_signout_in_progress_dialog_content))
is AsyncAction.Loading -> {
if (showProgressDialog) {
ProgressDialog(text = stringResource(id = R.string.screen_signout_in_progress_dialog_content))
}
}
is AsyncAction.Failure ->
RetryDialog(
title = stringResource(id = CommonStrings.dialog_title_error),