Make the sync response profile nonnull (#400)

This commit is contained in:
David Perez 2023-12-15 11:53:52 -06:00 committed by Álison Fernandes
parent 191602a867
commit 1b7e01ea89
3 changed files with 5 additions and 5 deletions

View file

@ -16,7 +16,7 @@ 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 ?: return this val userId = syncResponse.profile.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)

View file

@ -10,7 +10,7 @@ import java.time.LocalDateTime
* *
* @property folders A list of folders associated with the vault data (nullable). * @property folders A list of folders associated with the vault data (nullable).
* @property collections A list of collections associated with the vault data (nullable). * @property collections A list of collections associated with the vault data (nullable).
* @property profile The profile associated with the vault data (nullable). * @property profile The profile associated with the vault data.
* @property ciphers A list of ciphers associated with the vault data (nullable). * @property ciphers A list of ciphers associated with the vault data (nullable).
* @property policies A list of policies associated with the vault data (nullable). * @property policies A list of policies associated with the vault data (nullable).
* @property domains A domains object associated with the vault data. * @property domains A domains object associated with the vault data.
@ -25,7 +25,7 @@ data class SyncResponseJson(
val collections: List<Collection>?, val collections: List<Collection>?,
@SerialName("profile") @SerialName("profile")
val profile: Profile?, val profile: Profile,
@SerialName("ciphers") @SerialName("ciphers")
val ciphers: List<Cipher>?, val ciphers: List<Cipher>?,

View file

@ -312,7 +312,7 @@ class VaultRepositoryImpl constructor(
private fun storeKeys( private fun storeKeys(
syncResponse: SyncResponseJson, syncResponse: SyncResponseJson,
) { ) {
val profile = syncResponse.profile ?: return val profile = syncResponse.profile
val userId = profile.id val userId = profile.id
val userKey = profile.key val userKey = profile.key
val privateKey = profile.privateKey val privateKey = profile.privateKey
@ -338,7 +338,7 @@ class VaultRepositoryImpl constructor(
private suspend fun unlockVaultForOrganizationsIfNecessary( private suspend fun unlockVaultForOrganizationsIfNecessary(
syncResponse: SyncResponseJson, syncResponse: SyncResponseJson,
) { ) {
val profile = syncResponse.profile ?: return val profile = syncResponse.profile
val organizationKeys = profile.organizations val organizationKeys = profile.organizations
.orEmpty() .orEmpty()
.filter { it.key != null } .filter { it.key != null }