Updating getAuthCodesFlow to update values on emission. (#741)

This commit is contained in:
Oleg Semenenko 2024-01-23 21:55:08 -06:00 committed by Álison Fernandes
parent de99c36b20
commit eeb4ae75a7

View file

@ -32,7 +32,7 @@ class TotpCodeManagerImpl(
private val unconfinedScope = CoroutineScope(dispatcherManager.unconfined)
private val mutableVerificationCodeStateFlowMap =
mutableMapOf<String, StateFlow<DataState<VerificationCodeItem?>>>()
mutableMapOf<CipherView, StateFlow<DataState<VerificationCodeItem?>>>()
override fun getTotpCodesStateFlow(
userId: String,
@ -78,7 +78,7 @@ class TotpCodeManagerImpl(
): StateFlow<DataState<VerificationCodeItem?>> {
val cipherId = cipher.id ?: return MutableStateFlow(DataState.Loaded(null))
return mutableVerificationCodeStateFlowMap.getOrPut(cipherId) {
return mutableVerificationCodeStateFlowMap.getOrPut(cipher) {
flow<DataState<VerificationCodeItem?>> {
val totpCode = cipher
@ -134,7 +134,7 @@ class TotpCodeManagerImpl(
}
}
.onCompletion {
mutableVerificationCodeStateFlowMap.remove(cipherId)
mutableVerificationCodeStateFlowMap.remove(cipher)
}
.stateIn(
scope = unconfinedScope,