improvement: Show account name instead of account email in filters

This commit is contained in:
Artem Chepurnoy 2024-03-30 12:40:45 +02:00
parent 2e68f469a7
commit 8dbac9f841
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
8 changed files with 26 additions and 21 deletions

View File

@ -33,3 +33,7 @@ data class DProfile(
override fun accountId(): String = accountId
}
val DProfile.displayName: String
get() = name.takeIf { it.isNotBlank() }
?: email

View File

@ -15,6 +15,7 @@ import androidx.compose.ui.unit.dp
import arrow.core.andThen
import arrow.core.partially1
import com.artemchep.keyguard.common.model.Loadable
import com.artemchep.keyguard.common.model.displayName
import com.artemchep.keyguard.common.usecase.GetAccounts
import com.artemchep.keyguard.common.usecase.GetCollections
import com.artemchep.keyguard.common.usecase.GetFolders
@ -224,7 +225,7 @@ fun organizationConfirmationState(
(!premiumAccount || profile.premium)
AccountVariant(
accountId = profile.accountId(),
name = profile.email,
name = profile.displayName,
text = profile.accountHost,
enabled = enabled,
accentColors = profile.accentColor,

View File

@ -10,6 +10,7 @@ import com.artemchep.keyguard.common.model.AccountId
import com.artemchep.keyguard.common.model.AccountTask
import com.artemchep.keyguard.common.model.DAccount
import com.artemchep.keyguard.common.model.DProfile
import com.artemchep.keyguard.common.model.displayName
import com.artemchep.keyguard.common.model.firstOrNull
import com.artemchep.keyguard.common.usecase.GetAccountHasError
import com.artemchep.keyguard.common.usecase.GetAccounts
@ -241,7 +242,7 @@ fun accountListScreenState(
id = it.id.id,
icon = icon,
name = profile?.name.orEmpty(),
title = AnnotatedString(it.username),
title = AnnotatedString(profile?.displayName.orEmpty()),
text = it.host,
error = error,
hidden = profile?.hidden == true,

View File

@ -70,6 +70,7 @@ import com.artemchep.keyguard.common.model.create.state
import com.artemchep.keyguard.common.model.create.title
import com.artemchep.keyguard.common.model.create.username
import com.artemchep.keyguard.common.model.creditCards
import com.artemchep.keyguard.common.model.displayName
import com.artemchep.keyguard.common.model.fileName
import com.artemchep.keyguard.common.model.fileSize
import com.artemchep.keyguard.common.model.title
@ -1967,7 +1968,7 @@ private suspend fun RememberStateFlowScope.produceOwnershipFlow(
val key = "account.${account.accountId()}"
AddStateOwnership.Element.Item(
key = key,
title = account.email,
title = account.displayName,
text = account.accountHost,
accentColors = account.accentColor,
)

View File

@ -28,6 +28,7 @@ import com.artemchep.keyguard.common.model.DFolder
import com.artemchep.keyguard.common.model.DOrganization
import com.artemchep.keyguard.common.model.DProfile
import com.artemchep.keyguard.common.model.DSecret
import com.artemchep.keyguard.common.model.displayName
import com.artemchep.keyguard.common.model.iconImageVector
import com.artemchep.keyguard.common.model.titleH
import com.artemchep.keyguard.common.service.filter.AddCipherFilter
@ -549,7 +550,7 @@ suspend fun <
accountIds = setOf(
profile.accountId,
),
title = profile.email,
title = profile.displayName,
text = profile.accountHost,
tint = profile.accentColor,
)

View File

@ -679,8 +679,7 @@ fun sendListScreenState(
.map { state ->
state.list.mapNotNull { it as? SendItem.Item }
},
accountGetter = ::identity,
accountFlow = getAccounts(),
profileFlow = getProfiles(),
cipherGetter = {
it.model.source
},

View File

@ -41,6 +41,7 @@ import com.artemchep.keyguard.common.model.create.state
import com.artemchep.keyguard.common.model.create.text
import com.artemchep.keyguard.common.model.create.title
import com.artemchep.keyguard.common.model.create.username
import com.artemchep.keyguard.common.model.displayName
import com.artemchep.keyguard.common.model.titleH
import com.artemchep.keyguard.common.service.clipboard.ClipboardService
import com.artemchep.keyguard.common.service.logging.LogRepository
@ -531,7 +532,7 @@ private suspend fun RememberStateFlowScope.produceOwnershipFlow(
val key = "account.${account.accountId()}"
AddStateOwnership.Element.Item(
key = key,
title = account.email,
title = account.displayName,
text = account.accountHost,
accentColors = account.accentColor,
)

View File

@ -12,8 +12,10 @@ import androidx.compose.ui.unit.dp
import arrow.core.partially1
import arrow.core.widen
import com.artemchep.keyguard.common.model.DAccount
import com.artemchep.keyguard.common.model.DProfile
import com.artemchep.keyguard.common.model.DSend
import com.artemchep.keyguard.common.model.DSendFilter
import com.artemchep.keyguard.common.model.displayName
import com.artemchep.keyguard.common.model.iconImageVector
import com.artemchep.keyguard.common.model.titleH
import com.artemchep.keyguard.feature.home.vault.component.rememberSecretAccentColor
@ -115,14 +117,12 @@ data class FilterParams(
suspend fun <
Output : Any,
Account,
Secret,
> RememberStateFlowScope.ah(
directDI: DirectDI,
outputGetter: (Output) -> DSend,
outputFlow: Flow<List<Output>>,
accountGetter: (Account) -> DAccount,
accountFlow: Flow<List<Account>>,
profileFlow: Flow<List<DProfile>>,
cipherGetter: (Secret) -> DSend,
cipherFlow: Flow<List<Secret>>,
input: CreateFilterResult,
@ -301,20 +301,17 @@ suspend fun <
icon = type.iconImageVector(),
)
val filterAccountListFlow = accountFlow
.map { accounts ->
accounts
.map { account ->
val model = accountGetter(account)
val accountId = model.accountId()
val tint = generateAccentColorsByAccountId(accountId)
val filterAccountListFlow = profileFlow
.map { profiles ->
profiles
.map { profile ->
createAccountFilterAction(
accountIds = setOf(
model.accountId(),
profile.accountId,
),
title = model.username,
text = model.host,
tint = tint,
title = profile.displayName,
text = profile.accountHost,
tint = profile.accentColor,
)
}
}