mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 23:11:01 -05:00
Add isActive and isVaultUnlocked to AccountSummary (#361)
This commit is contained in:
committed by
Álison Fernandes
parent
5de9931d05
commit
8855fda026
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user