Lock : fix race condition on setup pin
This commit is contained in:
parent
04afa8c200
commit
05e99adfc4
4 changed files with 15 additions and 10 deletions
|
|
@ -17,6 +17,6 @@
|
|||
package io.element.android.features.lockscreen.impl.setup.pin
|
||||
|
||||
sealed interface SetupPinEvents {
|
||||
data class OnPinEntryChanged(val entryAsText: String) : SetupPinEvents
|
||||
data class OnPinEntryChanged(val entryAsText: String, val fromConfirmationStep: Boolean) : SetupPinEvents
|
||||
data object ClearFailure : SetupPinEvents
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ class SetupPinPresenter @Inject constructor(
|
|||
fun handleEvents(event: SetupPinEvents) {
|
||||
when (event) {
|
||||
is SetupPinEvents.OnPinEntryChanged -> {
|
||||
if (isConfirmationStep) {
|
||||
// Use the fromConfirmationStep flag from ui to avoid race condition.
|
||||
if (event.fromConfirmationStep) {
|
||||
confirmPinEntry = confirmPinEntry.fillWith(event.entryAsText)
|
||||
} else {
|
||||
choosePinEntry = choosePinEntry.fillWith(event.entryAsText)
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ private fun SetupPinContent(
|
|||
PinEntryTextField(
|
||||
pinEntry = state.activePinEntry,
|
||||
isSecured = true,
|
||||
onValueChange = {
|
||||
state.eventSink(SetupPinEvents.OnPinEntryChanged(it))
|
||||
onValueChange = { entry ->
|
||||
state.eventSink(SetupPinEvents.OnPinEntryChanged(entry, state.isConfirmationStep))
|
||||
},
|
||||
modifier = modifier
|
||||
.focusRequester(focusRequester)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue