mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Add biometrics state to UnlockVaultViewModel (#815)
This commit is contained in:
parent
49e3d555e3
commit
78a256ae3f
3 changed files with 21 additions and 9 deletions
|
@ -53,6 +53,7 @@ class VaultUnlockViewModel @Inject constructor(
|
|||
dialog = null,
|
||||
environmentUrl = environmentRepo.environment.label,
|
||||
input = "",
|
||||
isBiometricEnabled = userState.activeAccount.isBiometricsEnabled,
|
||||
vaultUnlockType = userState.activeAccount.vaultUnlockType,
|
||||
)
|
||||
},
|
||||
|
@ -87,13 +88,7 @@ class VaultUnlockViewModel @Inject constructor(
|
|||
is VaultUnlockAction.LogoutAccountClick -> handleLogoutAccountClick(action)
|
||||
is VaultUnlockAction.SwitchAccountClick -> handleSwitchAccountClick(action)
|
||||
VaultUnlockAction.UnlockClick -> handleUnlockClick()
|
||||
is VaultUnlockAction.Internal.ReceiveVaultUnlockResult -> {
|
||||
handleReceiveVaultUnlockResult(action)
|
||||
}
|
||||
|
||||
is VaultUnlockAction.Internal.UserStateUpdateReceive -> {
|
||||
handleUserStateUpdateReceive(action)
|
||||
}
|
||||
is VaultUnlockAction.Internal -> handleInternalAction(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,6 +148,18 @@ class VaultUnlockViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleInternalAction(action: VaultUnlockAction.Internal) {
|
||||
when (action) {
|
||||
is VaultUnlockAction.Internal.ReceiveVaultUnlockResult -> {
|
||||
handleReceiveVaultUnlockResult(action)
|
||||
}
|
||||
|
||||
is VaultUnlockAction.Internal.UserStateUpdateReceive -> {
|
||||
handleUserStateUpdateReceive(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleReceiveVaultUnlockResult(
|
||||
action: VaultUnlockAction.Internal.ReceiveVaultUnlockResult,
|
||||
) {
|
||||
|
@ -211,6 +218,7 @@ class VaultUnlockViewModel @Inject constructor(
|
|||
avatarColorString = activeAccountSummary.avatarColorHex,
|
||||
accountSummaries = accountSummaries,
|
||||
email = activeAccountSummary.email,
|
||||
isBiometricEnabled = userState.activeAccount.isBiometricsEnabled,
|
||||
vaultUnlockType = userState.activeAccount.vaultUnlockType,
|
||||
)
|
||||
}
|
||||
|
@ -229,6 +237,7 @@ data class VaultUnlockState(
|
|||
val environmentUrl: String,
|
||||
val dialog: VaultUnlockDialog?,
|
||||
val input: String,
|
||||
val isBiometricEnabled: Boolean,
|
||||
val vaultUnlockType: VaultUnlockType,
|
||||
) : Parcelable {
|
||||
|
||||
|
|
|
@ -377,5 +377,6 @@ private val DEFAULT_STATE: VaultUnlockState = VaultUnlockState(
|
|||
environmentUrl = DEFAULT_ENVIRONMENT_URL,
|
||||
initials = "AU",
|
||||
input = "",
|
||||
isBiometricEnabled = true,
|
||||
vaultUnlockType = VaultUnlockType.MASTER_PASSWORD,
|
||||
)
|
||||
|
|
|
@ -34,7 +34,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
|
|||
|
||||
private val mutableUserStateFlow = MutableStateFlow<UserState?>(DEFAULT_USER_STATE)
|
||||
private val environmentRepository = FakeEnvironmentRepository()
|
||||
private val authRepository = mockk<AuthRepository>() {
|
||||
private val authRepository = mockk<AuthRepository> {
|
||||
every { activeUserId } answers { mutableUserStateFlow.value?.activeUserId }
|
||||
every { userStateFlow } returns mutableUserStateFlow
|
||||
every { hasPendingAccountAddition } returns false
|
||||
|
@ -145,7 +145,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
|
|||
isPremium = true,
|
||||
isLoggedIn = true,
|
||||
isVaultUnlocked = false,
|
||||
isBiometricsEnabled = false,
|
||||
isBiometricsEnabled = true,
|
||||
organizations = emptyList(),
|
||||
),
|
||||
),
|
||||
|
@ -168,6 +168,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
|
|||
isVaultUnlocked = false,
|
||||
),
|
||||
),
|
||||
isBiometricEnabled = true,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
|
@ -557,6 +558,7 @@ private val DEFAULT_STATE: VaultUnlockState = VaultUnlockState(
|
|||
dialog = null,
|
||||
environmentUrl = Environment.Us.label,
|
||||
input = "",
|
||||
isBiometricEnabled = false,
|
||||
vaultUnlockType = VaultUnlockType.MASTER_PASSWORD,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue