BIT-1555: identity name bug (#1026)

This commit is contained in:
Ramsey Smith 2024-02-16 10:40:43 -07:00 committed by Álison Fernandes
parent 3b2d3a4668
commit cbc3940167
2 changed files with 11 additions and 5 deletions

View file

@ -834,8 +834,8 @@ data class VaultState(
* Represents an identity item within the vault, containing personal identification
* information.
*
* @property firstName The first name of the individual associated with this
* identity item.
* @property fullName The first and last name of the individual associated with
* this identity item.
*/
@Parcelize
data class Identity(
@ -845,9 +845,9 @@ data class VaultState(
override val extraIconList: List<IconRes> = emptyList(),
override val overflowOptions: List<ListingItemOverflowAction.VaultAction>,
override val shouldShowMasterPasswordReprompt: Boolean,
val firstName: Text?,
val fullName: Text?,
) : VaultItem() {
override val supportingLabel: Text? get() = firstName
override val supportingLabel: Text? get() = fullName
}
/**

View file

@ -10,6 +10,7 @@ import com.bitwarden.core.LoginUriView
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.vault.repository.model.VaultData
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.orNullIfBlank
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.vault.feature.util.toLabelIcons
import com.x8bit.bitwarden.ui.vault.feature.util.toOverflowActions
@ -211,7 +212,12 @@ private fun CipherView.toVaultItemOrNull(
CipherType.IDENTITY -> VaultState.ViewState.VaultItem.Identity(
id = id,
name = name.asText(),
firstName = identity?.firstName?.asText(),
fullName = when {
identity?.firstName.isNullOrBlank() -> identity?.lastName?.orNullIfBlank()
identity?.lastName.isNullOrBlank() -> identity?.firstName
else -> "${identity?.firstName} ${identity?.lastName}"
}
?.asText(),
overflowOptions = toOverflowActions(),
extraIconList = toLabelIcons(),
shouldShowMasterPasswordReprompt = reprompt == CipherRepromptType.PASSWORD,