mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Logout: do not double render the progress state and disable the cancel button during the process.
This commit is contained in:
+6
@@ -47,6 +47,9 @@ import io.element.android.libraries.testtags.TestTags
|
|||||||
import io.element.android.libraries.testtags.testTag
|
import io.element.android.libraries.testtags.testTag
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
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
|
@Composable
|
||||||
fun LogoutView(
|
fun LogoutView(
|
||||||
state: LogoutState,
|
state: LogoutState,
|
||||||
@@ -78,6 +81,8 @@ fun LogoutView(
|
|||||||
|
|
||||||
LogoutActionDialog(
|
LogoutActionDialog(
|
||||||
state.logoutAction,
|
state.logoutAction,
|
||||||
|
// Do not show the progress dialog, the progress is rendered in the button.
|
||||||
|
showProgressDialog = false,
|
||||||
onConfirmClick = {
|
onConfirmClick = {
|
||||||
eventSink(LogoutEvent.Logout(ignoreSdkError = false))
|
eventSink(LogoutEvent.Logout(ignoreSdkError = false))
|
||||||
},
|
},
|
||||||
@@ -149,6 +154,7 @@ private fun ColumnScope.Buttons(
|
|||||||
)
|
)
|
||||||
TextButton(
|
TextButton(
|
||||||
text = stringResource(id = CommonStrings.action_cancel),
|
text = stringResource(id = CommonStrings.action_cancel),
|
||||||
|
enabled = logoutAction !is AsyncAction.Loading,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = onCancelClick,
|
onClick = onCancelClick,
|
||||||
)
|
)
|
||||||
|
|||||||
+1
@@ -27,6 +27,7 @@ class DefaultDirectLogoutView : DirectLogoutView {
|
|||||||
val eventSink = state.eventSink
|
val eventSink = state.eventSink
|
||||||
LogoutActionDialog(
|
LogoutActionDialog(
|
||||||
state.logoutAction,
|
state.logoutAction,
|
||||||
|
showProgressDialog = true,
|
||||||
onConfirmClick = {
|
onConfirmClick = {
|
||||||
eventSink(DirectLogoutEvent.Logout(ignoreSdkError = false))
|
eventSink(DirectLogoutEvent.Logout(ignoreSdkError = false))
|
||||||
},
|
},
|
||||||
|
|||||||
+6
-2
@@ -19,6 +19,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
|||||||
@Composable
|
@Composable
|
||||||
fun LogoutActionDialog(
|
fun LogoutActionDialog(
|
||||||
state: AsyncAction<Unit>,
|
state: AsyncAction<Unit>,
|
||||||
|
showProgressDialog: Boolean,
|
||||||
onConfirmClick: () -> Unit,
|
onConfirmClick: () -> Unit,
|
||||||
onForceLogoutClick: () -> Unit,
|
onForceLogoutClick: () -> Unit,
|
||||||
onDismissDialog: () -> Unit,
|
onDismissDialog: () -> Unit,
|
||||||
@@ -31,8 +32,11 @@ fun LogoutActionDialog(
|
|||||||
onSubmitClick = onConfirmClick,
|
onSubmitClick = onConfirmClick,
|
||||||
onDismiss = onDismissDialog
|
onDismiss = onDismissDialog
|
||||||
)
|
)
|
||||||
is AsyncAction.Loading ->
|
is AsyncAction.Loading -> {
|
||||||
ProgressDialog(text = stringResource(id = R.string.screen_signout_in_progress_dialog_content))
|
if (showProgressDialog) {
|
||||||
|
ProgressDialog(text = stringResource(id = R.string.screen_signout_in_progress_dialog_content))
|
||||||
|
}
|
||||||
|
}
|
||||||
is AsyncAction.Failure ->
|
is AsyncAction.Failure ->
|
||||||
RetryDialog(
|
RetryDialog(
|
||||||
title = stringResource(id = CommonStrings.dialog_title_error),
|
title = stringResource(id = CommonStrings.dialog_title_error),
|
||||||
|
|||||||
Reference in New Issue
Block a user