Simplify and rename the hasManualUnlockMechanism helper (#1322)

This commit is contained in:
David Perez
2024-04-30 15:51:14 -05:00
committed by GitHub
parent 0d398a4b5f
commit 3be55288dc
2 changed files with 7 additions and 6 deletions

View File

@@ -72,12 +72,13 @@ data class UserState(
val hasMasterPassword: Boolean get() = trustedDevice?.hasMasterPassword != false
/**
* Indicates that the user does or does not have a means to unlock the vault.
* Indicates that the user does or does not have a means to manually unlock the vault.
*/
val hasUnlockMechanism: Boolean
get() = hasMasterPassword ||
isBiometricsEnabled ||
vaultUnlockType == VaultUnlockType.PIN
val hasManualUnlockMechanism: Boolean
get() = when (vaultUnlockType) {
VaultUnlockType.MASTER_PASSWORD -> hasMasterPassword || isBiometricsEnabled
VaultUnlockType.PIN -> true
}
}
/**

View File

@@ -62,7 +62,7 @@ class RootNavViewModel @Inject constructor(
val updatedRootNavState = when {
userState?.activeAccount?.trustedDevice?.isDeviceTrusted == false &&
!userState.activeAccount.isVaultUnlocked &&
!userState.activeAccount.hasUnlockMechanism -> RootNavState.TrustedDevice
!userState.activeAccount.hasManualUnlockMechanism -> RootNavState.TrustedDevice
userState?.activeAccount?.needsMasterPassword == true -> RootNavState.SetPassword