mirror of
https://github.com/bitwarden/android.git
synced 2024-11-23 18:06:08 +03:00
Ensure hasPremium value is set on profile (#534)
This commit is contained in:
parent
ab5ea4ebaa
commit
0ee25a3dd5
3 changed files with 8 additions and 4 deletions
|
@ -17,14 +17,16 @@ import com.x8bit.bitwarden.ui.platform.base.util.toHexColorRepresentation
|
||||||
fun UserStateJson.toUpdatedUserStateJson(
|
fun UserStateJson.toUpdatedUserStateJson(
|
||||||
syncResponse: SyncResponseJson,
|
syncResponse: SyncResponseJson,
|
||||||
): UserStateJson {
|
): UserStateJson {
|
||||||
val userId = syncResponse.profile.id
|
val syncProfile = syncResponse.profile
|
||||||
|
val userId = syncProfile.id
|
||||||
val account = this.accounts[userId] ?: return this
|
val account = this.accounts[userId] ?: return this
|
||||||
val profile = account.profile
|
val profile = account.profile
|
||||||
// TODO: Update additional missing UserStateJson properties (BIT-916)
|
// TODO: Update additional missing UserStateJson properties (BIT-916)
|
||||||
val updatedProfile = profile
|
val updatedProfile = profile
|
||||||
.copy(
|
.copy(
|
||||||
avatarColorHex = syncResponse.profile.avatarColor,
|
avatarColorHex = syncProfile.avatarColor,
|
||||||
stamp = syncResponse.profile.securityStamp,
|
stamp = syncProfile.securityStamp,
|
||||||
|
hasPremium = syncProfile.isPremium || syncProfile.isPremiumFromOrganization,
|
||||||
)
|
)
|
||||||
val updatedAccount = account.copy(profile = updatedProfile)
|
val updatedAccount = account.copy(profile = updatedProfile)
|
||||||
return this
|
return this
|
||||||
|
|
|
@ -83,6 +83,8 @@ class UserStateJsonExtensionsTest {
|
||||||
every { id } returns "activeUserId"
|
every { id } returns "activeUserId"
|
||||||
every { avatarColor } returns "avatarColor"
|
every { avatarColor } returns "avatarColor"
|
||||||
every { securityStamp } returns "securityStamp"
|
every { securityStamp } returns "securityStamp"
|
||||||
|
every { isPremium } returns true
|
||||||
|
every { isPremiumFromOrganization } returns true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -2121,7 +2121,7 @@ private val MOCK_PROFILE = AccountJson.Profile(
|
||||||
stamp = null,
|
stamp = null,
|
||||||
organizationId = null,
|
organizationId = null,
|
||||||
avatarColorHex = null,
|
avatarColorHex = null,
|
||||||
hasPremium = true,
|
hasPremium = false,
|
||||||
forcePasswordResetReason = null,
|
forcePasswordResetReason = null,
|
||||||
kdfType = null,
|
kdfType = null,
|
||||||
kdfIterations = null,
|
kdfIterations = null,
|
||||||
|
|
Loading…
Reference in a new issue