Fix: last digit of send amount always lingers when returning to home screen
This commit is contained in:
parent
3d4ae2ae63
commit
f724a74993
|
@ -21,8 +21,7 @@ class HomeViewModel @Inject constructor() : ViewModel() {
|
||||||
|
|
||||||
lateinit var uiModels: Flow<UiModel>
|
lateinit var uiModels: Flow<UiModel>
|
||||||
|
|
||||||
private val _typedChars = ConflatedBroadcastChannel<Char>()
|
lateinit var _typedChars: ConflatedBroadcastChannel<Char>
|
||||||
private val typedChars = _typedChars.asFlow()
|
|
||||||
|
|
||||||
var initialized = false
|
var initialized = false
|
||||||
|
|
||||||
|
@ -32,12 +31,19 @@ class HomeViewModel @Inject constructor() : ViewModel() {
|
||||||
twig("Warning already initialized HomeViewModel. Ignoring call to initialize.")
|
twig("Warning already initialized HomeViewModel. Ignoring call to initialize.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (::_typedChars.isInitialized) {
|
||||||
|
_typedChars.close()
|
||||||
|
}
|
||||||
|
_typedChars = ConflatedBroadcastChannel()
|
||||||
|
val typedChars = _typedChars.asFlow()
|
||||||
|
|
||||||
val zec = typedChars.scan("0") { acc, c ->
|
val zec = typedChars.scan("0") { acc, c ->
|
||||||
when {
|
when {
|
||||||
// no-op cases
|
// no-op cases
|
||||||
acc == "0" && c == '0'
|
acc == "0" && c == '0'
|
||||||
|| (c == '<' && acc == "0")
|
|| (c == '<' && acc == "0")
|
||||||
|| (c == '.' && acc.contains('.')) -> {twig("triggered: 1 acc: $acc c: $c $typedChars ")
|
|| (c == '.' && acc.contains('.')) -> {twig("triggered: 1 acc: $acc c: $c")
|
||||||
acc
|
acc
|
||||||
}
|
}
|
||||||
c == '<' && acc.length <= 1 -> {twig("triggered: 2 $typedChars")
|
c == '<' && acc.length <= 1 -> {twig("triggered: 2 $typedChars")
|
||||||
|
|
Loading…
Reference in New Issue