[Link new device] Add missing screen for the error case OtherDeviceAlreadySignedIn

Closes #6678
This commit is contained in:
Benoit Marty 2026-04-29 11:11:43 +02:00 committed by Benoit Marty
parent 7dd81dc838
commit 083fc5c5fb
4 changed files with 32 additions and 8 deletions

View file

@ -199,9 +199,7 @@ class LinkNewDeviceFlowNode(
is ErrorType.Expired,
is ErrorType.NotFound,
is ErrorType.DeviceNotFound -> ErrorScreenType.Expired
// TODO we should show other_device_already_signed_in screen with checkmark when available
// See: https://github.com/element-hq/element-x-android/issues/6678
is ErrorType.OtherDeviceAlreadySignedIn -> ErrorScreenType.UnknownError
is ErrorType.OtherDeviceAlreadySignedIn -> ErrorScreenType.OtherDeviceAlreadySignedIn
// TODO check if we expect to hit this here or if it should be caught earlier on
is ErrorType.UnsupportedQrCodeType -> ErrorScreenType.UnknownError
is ErrorType.MissingSecretsBackup,

View file

@ -20,6 +20,9 @@ sealed interface ErrorScreenType : NodeInputs, Parcelable {
@Parcelize
data object Expired : ErrorScreenType
@Parcelize
data object OtherDeviceAlreadySignedIn : ErrorScreenType
@Parcelize
data object Mismatch2Digits : ErrorScreenType

View file

@ -19,5 +19,6 @@ class ErrorScreenTypeProvider : PreviewParameterProvider<ErrorScreenType> {
ErrorScreenType.InsecureChannelDetected,
ErrorScreenType.SlidingSyncNotAvailable,
ErrorScreenType.UnknownError,
ErrorScreenType.OtherDeviceAlreadySignedIn,
)
}

View file

@ -47,17 +47,26 @@ fun ErrorView(
) {
val appName = LocalBuildMeta.current.applicationName
BackHandler(onBack = onCancel)
val iconStyle = when (errorScreenType) {
ErrorScreenType.OtherDeviceAlreadySignedIn -> BigIcon.Style.SuccessSolid
else -> BigIcon.Style.AlertSolid
}
FlowStepPage(
modifier = modifier,
iconStyle = BigIcon.Style.AlertSolid,
iconStyle = iconStyle,
title = titleText(errorScreenType, appName),
subTitle = subtitleText(errorScreenType, appName),
content = { Content(errorScreenType) },
buttons = {
Buttons(
onRetry = onRetry,
onCancel = onCancel,
)
when (errorScreenType) {
ErrorScreenType.OtherDeviceAlreadySignedIn -> DoneButton(
onDone = onCancel,
)
else -> Buttons(
onRetry = onRetry,
onCancel = onCancel,
)
}
},
)
}
@ -72,6 +81,7 @@ private fun titleText(errorScreenType: ErrorScreenType, appName: String) = when
ErrorScreenType.Mismatch2Digits -> stringResource(id = R.string.screen_link_new_device_wrong_number_title)
ErrorScreenType.SlidingSyncNotAvailable -> stringResource(id = R.string.screen_qr_code_login_error_sliding_sync_not_supported_title, appName)
is ErrorScreenType.UnknownError -> stringResource(CommonStrings.common_something_went_wrong)
ErrorScreenType.OtherDeviceAlreadySignedIn -> stringResource(R.string.screen_qr_code_login_error_device_already_signed_in_title)
}
@Composable
@ -84,6 +94,7 @@ private fun subtitleText(errorScreenType: ErrorScreenType, appName: String) = wh
ErrorScreenType.InsecureChannelDetected -> stringResource(id = R.string.screen_qr_code_login_connection_note_secure_state_description)
ErrorScreenType.SlidingSyncNotAvailable -> stringResource(id = R.string.screen_qr_code_login_error_sliding_sync_not_supported_subtitle, appName)
is ErrorScreenType.UnknownError -> stringResource(R.string.screen_qr_code_login_unknown_error_description)
ErrorScreenType.OtherDeviceAlreadySignedIn -> stringResource(R.string.screen_qr_code_login_error_device_already_signed_in_subtitle)
}
@Composable
@ -124,6 +135,17 @@ private fun Content(errorScreenType: ErrorScreenType) {
}
}
@Composable
private fun DoneButton(
onDone: () -> Unit,
) {
Button(
modifier = Modifier.fillMaxWidth(),
text = stringResource(CommonStrings.action_done),
onClick = onDone,
)
}
@Composable
private fun Buttons(
onRetry: () -> Unit,