Add isActive and isVaultUnlocked to AccountSummary (#361)

This commit is contained in:
Brian Yencho
2023-12-11 09:29:23 -06:00
committed by Álison Fernandes
parent 5de9931d05
commit 8855fda026
9 changed files with 51 additions and 49 deletions

View File

@@ -14,7 +14,8 @@ import kotlinx.parcelize.Parcelize
* @property avatarColorHex Hex color value for a user's avatar in the "#AARRGGBB" format.
* @property environmentLabel Label for the environment associated with the user's account
* (ex: "bitwarden.com"). This is purely for display purposes.
* @property status The current status of the user's account locally.
* @property isActive Whether or not the account is currently the active one.
* @property isVaultUnlocked Whether or not the account's vault is currently unlocked.
*/
@Parcelize
data class AccountSummary(
@@ -23,7 +24,8 @@ data class AccountSummary(
val email: String,
val avatarColorHex: String,
val environmentLabel: String,
val status: Status,
val isActive: Boolean,
val isVaultUnlocked: Boolean,
) : Parcelable {
/**
@@ -32,6 +34,16 @@ data class AccountSummary(
val avatarColor: Color
get() = avatarColorHex.hexToColor()
/**
* The current status of the user's account locally.
*/
val status: Status
get() = when {
isActive -> Status.ACTIVE
isVaultUnlocked -> Status.UNLOCKED
else -> Status.LOCKED
}
/**
* Describes the status of the given account.
*/

View File

@@ -36,9 +36,6 @@ fun UserState.Account.toAccountSummary(
email = this.email,
avatarColorHex = this.avatarColorHex,
environmentLabel = this.environment.label,
status = when {
isActive -> AccountSummary.Status.ACTIVE
this.isVaultUnlocked -> AccountSummary.Status.UNLOCKED
else -> AccountSummary.Status.LOCKED
},
isActive = isActive,
isVaultUnlocked = this.isVaultUnlocked,
)