improvement(Vault): Clear search query on first back press

This commit is contained in:
Artem Chepurnoy 2024-06-19 08:09:22 +03:00
parent 54fe90fcc0
commit f8c77ea34d
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 18 additions and 0 deletions

View File

@ -330,6 +330,24 @@ fun vaultListScreenState(
val querySink = mutablePersistedFlow("query") { "" }
val queryState = mutableComposeState(querySink)
// Intercept the back button while the
// search query is not empty.
interceptBackPress(
interceptorFlow = querySink
.map { it.isNotEmpty() }
.distinctUntilChanged()
.map { enabled ->
if (enabled) {
// lambda
{
queryState.value = ""
}
} else {
null
}
},
)
val cipherSink = EventFlow<DSecret>()
val itemSink = mutablePersistedFlow("lole") { "" }