Allow null for isRegistered in storeVaultRegisteredForExport

This commit is contained in:
Patrick Honkonen 2024-11-19 15:56:11 -05:00
parent 3c22e2dd2d
commit 2c5830147d
No known key found for this signature in database
GPG key ID: B63AF42A5531C877
3 changed files with 7 additions and 6 deletions

View file

@ -330,7 +330,7 @@ interface SettingsDiskSource {
* Stores the given value for whether or not the given [userId] has registered for export via
* the credential exchange protocol.
*/
fun storeVaultRegisteredForExport(userId: String, isRegistered: Boolean)
fun storeVaultRegisteredForExport(userId: String, isRegistered: Boolean?)
/**
* Emits updates that track [getVaultRegisteredForExport] for the given [userId].

View file

@ -185,6 +185,7 @@ class SettingsDiskSourceImpl(
storeLastSyncTime(userId = userId, lastSyncTime = null)
storeClearClipboardFrequencySeconds(userId = userId, frequency = null)
removeWithPrefix(prefix = ACCOUNT_BIOMETRIC_INTEGRITY_VALID_KEY.appendIdentifier(userId))
storeVaultRegisteredForExport(userId = userId, isRegistered = null)
// The following are intentionally not cleared so they can be
// restored after logging out and back in:
@ -450,7 +451,7 @@ class SettingsDiskSourceImpl(
override fun getVaultRegisteredForExport(userId: String): Boolean? =
getBoolean(IS_VAULT_REGISTERED_FOR_EXPORT.appendIdentifier(userId))
override fun storeVaultRegisteredForExport(userId: String, isRegistered: Boolean) {
override fun storeVaultRegisteredForExport(userId: String, isRegistered: Boolean?) {
putBoolean(IS_VAULT_REGISTERED_FOR_EXPORT.appendIdentifier(userId), isRegistered)
getMutableVaultRegisteredForExportFlow(userId).tryEmit(isRegistered)
}

View file

@ -68,7 +68,7 @@ class FakeSettingsDiskSource : SettingsDiskSource {
private val userShowUnlockBadge = mutableMapOf<String, Boolean?>()
private val userShowImportLoginsBadge = mutableMapOf<String, Boolean?>()
private var storedLastDatabaseSchemeChangeInstant: Instant? = null
private val vaultRegisteredForExport = mutableMapOf<String, Boolean>()
private val vaultRegisteredForExport = mutableMapOf<String, Boolean?>()
private val mutableShowAutoFillSettingBadgeFlowMap =
mutableMapOf<String, MutableSharedFlow<Boolean?>>()
@ -80,7 +80,7 @@ class FakeSettingsDiskSource : SettingsDiskSource {
mutableMapOf<String, MutableSharedFlow<Boolean?>>()
private val mutableVaultRegisteredForExportFlowMap =
mutableMapOf<String, MutableSharedFlow<Boolean>>()
mutableMapOf<String, MutableSharedFlow<Boolean?>>()
override var appLanguage: AppLanguage? = null
@ -357,7 +357,7 @@ class FakeSettingsDiskSource : SettingsDiskSource {
override fun getVaultRegisteredForExport(userId: String): Boolean =
vaultRegisteredForExport[userId] ?: false
override fun storeVaultRegisteredForExport(userId: String, registered: Boolean) {
override fun storeVaultRegisteredForExport(userId: String, registered: Boolean?) {
vaultRegisteredForExport[userId] = registered
getMutableVaultRegisteredForExportFlow(userId = userId).tryEmit(registered)
}
@ -421,7 +421,7 @@ class FakeSettingsDiskSource : SettingsDiskSource {
private fun getMutableVaultRegisteredForExportFlow(
userId: String,
): MutableSharedFlow<Boolean> =
): MutableSharedFlow<Boolean?> =
mutableVaultRegisteredForExportFlowMap.getOrPut(userId) {
bufferedMutableSharedFlow(replay = 1)
}