mirror of
https://github.com/bitwarden/android.git
synced 2026-06-04 03:36:32 -05:00
BIT-1715: Fix autofill account-switching data loading error (#965)
This commit is contained in:
committed by
Álison Fernandes
parent
ce9dff7ab2
commit
390411ded7
@@ -50,4 +50,9 @@ interface VaultLockManager {
|
||||
initUserCryptoMethod: InitUserCryptoMethod,
|
||||
organizationKeys: Map<String, String>?,
|
||||
): VaultUnlockResult
|
||||
|
||||
/**
|
||||
* Suspends until the vault for the given [userId] is unlocked.
|
||||
*/
|
||||
suspend fun waitUntilUnlocked(userId: String)
|
||||
}
|
||||
|
||||
@@ -176,6 +176,17 @@ class VaultLockManagerImpl(
|
||||
.onCompletion { setVaultToNotUnlocking(userId = userId) }
|
||||
.first()
|
||||
|
||||
override suspend fun waitUntilUnlocked(userId: String) {
|
||||
vaultUnlockDataStateFlow
|
||||
.map { vaultUnlockDataList ->
|
||||
// Get the list of currently-unlocked vaults and map them to user IDs.
|
||||
vaultUnlockDataList
|
||||
.filter { it.status == VaultUnlockData.Status.UNLOCKED }
|
||||
.map { it.userId }
|
||||
}
|
||||
.first { unlockedUserIds -> userId in unlockedUserIds }
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the stored invalid unlock count for the given [userId] and automatically logs out
|
||||
* if this new value is greater than [MAXIMUM_INVALID_UNLOCK_ATTEMPTS].
|
||||
|
||||
@@ -1289,6 +1289,7 @@ class VaultRepositoryImpl(
|
||||
mutableCiphersStateFlow.value = DataState.Loading
|
||||
}
|
||||
.map {
|
||||
waitUntilUnlocked(userId = userId)
|
||||
vaultSdkSource
|
||||
.decryptCipherList(
|
||||
userId = userId,
|
||||
@@ -1321,6 +1322,7 @@ class VaultRepositoryImpl(
|
||||
.getFolders(userId = userId)
|
||||
.onStart { mutableFoldersStateFlow.value = DataState.Loading }
|
||||
.map {
|
||||
waitUntilUnlocked(userId = userId)
|
||||
vaultSdkSource
|
||||
.decryptFolderList(
|
||||
userId = userId,
|
||||
@@ -1340,6 +1342,7 @@ class VaultRepositoryImpl(
|
||||
.getCollections(userId = userId)
|
||||
.onStart { mutableCollectionsStateFlow.value = DataState.Loading }
|
||||
.map {
|
||||
waitUntilUnlocked(userId = userId)
|
||||
vaultSdkSource
|
||||
.decryptCollectionList(
|
||||
userId = userId,
|
||||
@@ -1363,6 +1366,7 @@ class VaultRepositoryImpl(
|
||||
.getSends(userId = userId)
|
||||
.onStart { mutableSendDataStateFlow.value = DataState.Loading }
|
||||
.map {
|
||||
waitUntilUnlocked(userId = userId)
|
||||
vaultSdkSource
|
||||
.decryptSendList(
|
||||
userId = userId,
|
||||
|
||||
Reference in New Issue
Block a user