mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-20 00:35:47 +01:00
Ensure code entry actions are drained, even when not used.
This commit is contained in:
+12
@@ -21,6 +21,7 @@ import org.signal.appsettings.totpcodeentry.TotpCodeEntryState
|
||||
import org.signal.appsettings.totpcodeentry.TotpCodeEntryState.Error
|
||||
import org.signal.core.ui.compose.EventDrivenViewModel
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.uicomponents.codeentryfield.CodeEntryFieldAction
|
||||
import org.signal.uicomponents.codeentryfield.CodeEntryFieldPresenter
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,11 @@ class TotpCodeEntryViewModel(
|
||||
.state
|
||||
.onEach { onEvent(TotpCodeEntryEvent.CodeEntryStateChanged(it)) }
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
codeEntryPresenter
|
||||
.actions
|
||||
.onEach { onEvent(TotpCodeEntryEvent.CodeEntryAction(it)) }
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override suspend fun processEvent(event: TotpCodeEntryEvent) {
|
||||
@@ -62,6 +68,12 @@ class TotpCodeEntryViewModel(
|
||||
is TotpCodeEntryEvent.CodeEntryStateChanged -> {
|
||||
_state.update { it.copy(codeEntry = event.codeEntryState) }
|
||||
}
|
||||
is TotpCodeEntryEvent.CodeEntryAction -> {
|
||||
when (event.action) {
|
||||
// The user submits with the Next button, so a finished code doesn't need anything done with it here.
|
||||
is CodeEntryFieldAction.CodeEntered -> Unit
|
||||
}
|
||||
}
|
||||
TotpCodeEntryEvent.NextClicked -> {
|
||||
if (!_state.value.canSubmit) {
|
||||
return
|
||||
|
||||
+4
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.signal.appsettings.totpcodeentry
|
||||
|
||||
import org.signal.uicomponents.codeentryfield.CodeEntryFieldAction
|
||||
import org.signal.uicomponents.codeentryfield.CodeEntryFieldEvents
|
||||
import org.signal.uicomponents.codeentryfield.CodeEntryFieldState
|
||||
|
||||
@@ -22,6 +23,9 @@ sealed interface TotpCodeEntryEvent {
|
||||
/** The code field's presenter emitted new state for us to mirror. */
|
||||
data class CodeEntryStateChanged(val codeEntryState: CodeEntryFieldState) : TotpCodeEntryEvent
|
||||
|
||||
/** The code field's presenter emitted an action for us to carry out. */
|
||||
data class CodeEntryAction(val action: CodeEntryFieldAction) : TotpCodeEntryEvent
|
||||
|
||||
/** The user submitted the code they entered. */
|
||||
data object NextClicked : TotpCodeEntryEvent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user