mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
SecureBackupRootEvents -> SecureBackupRootEvent
This commit is contained in:
+5
-5
@@ -8,9 +8,9 @@
|
||||
|
||||
package io.element.android.features.securebackup.impl.root
|
||||
|
||||
sealed interface SecureBackupRootEvents {
|
||||
data object RetryKeyBackupState : SecureBackupRootEvents
|
||||
data object EnableKeyStorage : SecureBackupRootEvents
|
||||
data object DisplayKeyStorageDisabledError : SecureBackupRootEvents
|
||||
data object DismissDialog : SecureBackupRootEvents
|
||||
sealed interface SecureBackupRootEvent {
|
||||
data object RetryKeyBackupState : SecureBackupRootEvent
|
||||
data object EnableKeyStorage : SecureBackupRootEvent
|
||||
data object DisplayKeyStorageDisabledError : SecureBackupRootEvent
|
||||
data object DismissDialog : SecureBackupRootEvent
|
||||
}
|
||||
+5
-5
@@ -59,15 +59,15 @@ class SecureBackupRootPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
fun handleEvent(event: SecureBackupRootEvents) {
|
||||
fun handleEvent(event: SecureBackupRootEvent) {
|
||||
when (event) {
|
||||
SecureBackupRootEvents.RetryKeyBackupState -> localCoroutineScope.getKeyBackupStatus(doesBackupExistOnServerAction)
|
||||
SecureBackupRootEvents.EnableKeyStorage -> localCoroutineScope.enableBackup(enableAction)
|
||||
SecureBackupRootEvents.DismissDialog -> {
|
||||
SecureBackupRootEvent.RetryKeyBackupState -> localCoroutineScope.getKeyBackupStatus(doesBackupExistOnServerAction)
|
||||
SecureBackupRootEvent.EnableKeyStorage -> localCoroutineScope.enableBackup(enableAction)
|
||||
SecureBackupRootEvent.DismissDialog -> {
|
||||
enableAction.value = AsyncAction.Uninitialized
|
||||
displayKeyStorageDisabledError = false
|
||||
}
|
||||
SecureBackupRootEvents.DisplayKeyStorageDisabledError -> displayKeyStorageDisabledError = true
|
||||
SecureBackupRootEvent.DisplayKeyStorageDisabledError -> displayKeyStorageDisabledError = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ data class SecureBackupRootState(
|
||||
val appName: String,
|
||||
val displayKeyStorageDisabledError: Boolean,
|
||||
val snackbarMessage: SnackbarMessage?,
|
||||
val eventSink: (SecureBackupRootEvents) -> Unit,
|
||||
val eventSink: (SecureBackupRootEvent) -> Unit,
|
||||
) {
|
||||
val isKeyStorageEnabled: Boolean
|
||||
get() = when (backupState) {
|
||||
|
||||
+7
-7
@@ -114,12 +114,12 @@ fun SecureBackupRootView(
|
||||
if (state.doesBackupExistOnServer.data) {
|
||||
onDisableClick()
|
||||
} else {
|
||||
state.eventSink.invoke(SecureBackupRootEvents.EnableKeyStorage)
|
||||
state.eventSink.invoke(SecureBackupRootEvent.EnableKeyStorage)
|
||||
}
|
||||
}
|
||||
is AsyncData.Loading,
|
||||
AsyncData.Uninitialized -> Unit
|
||||
is AsyncData.Failure -> state.eventSink.invoke(SecureBackupRootEvents.RetryKeyBackupState)
|
||||
is AsyncData.Failure -> state.eventSink.invoke(SecureBackupRootEvent.RetryKeyBackupState)
|
||||
}
|
||||
}
|
||||
BackupState.CREATING,
|
||||
@@ -154,7 +154,7 @@ fun SecureBackupRootView(
|
||||
if (state.isKeyStorageEnabled) {
|
||||
onSetupClick()
|
||||
} else {
|
||||
state.eventSink.invoke(SecureBackupRootEvents.DisplayKeyStorageDisabledError)
|
||||
state.eventSink.invoke(SecureBackupRootEvent.DisplayKeyStorageDisabledError)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -177,7 +177,7 @@ fun SecureBackupRootView(
|
||||
if (state.isKeyStorageEnabled) {
|
||||
onChangeClick()
|
||||
} else {
|
||||
state.eventSink.invoke(SecureBackupRootEvents.DisplayKeyStorageDisabledError)
|
||||
state.eventSink.invoke(SecureBackupRootEvent.DisplayKeyStorageDisabledError)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -201,7 +201,7 @@ fun SecureBackupRootView(
|
||||
if (state.isKeyStorageEnabled) {
|
||||
onConfirmRecoveryKeyClick()
|
||||
} else {
|
||||
state.eventSink.invoke(SecureBackupRootEvents.DisplayKeyStorageDisabledError)
|
||||
state.eventSink.invoke(SecureBackupRootEvent.DisplayKeyStorageDisabledError)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -212,13 +212,13 @@ fun SecureBackupRootView(
|
||||
async = state.enableAction,
|
||||
progressDialog = { },
|
||||
onSuccess = { },
|
||||
onErrorDismiss = { state.eventSink.invoke(SecureBackupRootEvents.DismissDialog) }
|
||||
onErrorDismiss = { state.eventSink.invoke(SecureBackupRootEvent.DismissDialog) }
|
||||
)
|
||||
if (state.displayKeyStorageDisabledError) {
|
||||
ErrorDialog(
|
||||
title = null,
|
||||
content = stringResource(id = R.string.screen_chat_backup_key_storage_disabled_error),
|
||||
onSubmit = { state.eventSink.invoke(SecureBackupRootEvents.DismissDialog) },
|
||||
onSubmit = { state.eventSink.invoke(SecureBackupRootEvent.DismissDialog) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -66,7 +66,7 @@ class SecureBackupRootPresenterTest {
|
||||
val errorState = awaitItem()
|
||||
assertThat(errorState.doesBackupExistOnServer).isEqualTo(AsyncData.Failure<Boolean>(AN_EXCEPTION))
|
||||
encryptionService.givenDoesBackupExistOnServerResult(Result.success(false))
|
||||
errorState.eventSink.invoke(SecureBackupRootEvents.RetryKeyBackupState)
|
||||
errorState.eventSink.invoke(SecureBackupRootEvent.RetryKeyBackupState)
|
||||
val loadingState2 = awaitItem()
|
||||
assertThat(loadingState2.doesBackupExistOnServer).isInstanceOf(AsyncData.Loading::class.java)
|
||||
val finalState = awaitItem()
|
||||
@@ -82,9 +82,9 @@ class SecureBackupRootPresenterTest {
|
||||
}.test {
|
||||
skipItems(2)
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(SecureBackupRootEvents.DisplayKeyStorageDisabledError)
|
||||
initialState.eventSink(SecureBackupRootEvent.DisplayKeyStorageDisabledError)
|
||||
assertThat(awaitItem().displayKeyStorageDisabledError).isTrue()
|
||||
initialState.eventSink(SecureBackupRootEvents.DismissDialog)
|
||||
initialState.eventSink(SecureBackupRootEvent.DismissDialog)
|
||||
assertThat(awaitItem().displayKeyStorageDisabledError).isFalse()
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class SecureBackupRootPresenterTest {
|
||||
}.test {
|
||||
skipItems(2)
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(SecureBackupRootEvents.EnableKeyStorage)
|
||||
initialState.eventSink(SecureBackupRootEvent.EnableKeyStorage)
|
||||
assertThat(awaitItem().enableAction.isLoading()).isTrue()
|
||||
assertThat(awaitItem().enableAction.isSuccess()).isTrue()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user