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