diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt | 14 | ||||
-rw-r--r-- | app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt | 7 |
2 files changed, 14 insertions, 7 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt index f157cb12..04a57635 100644 --- a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt +++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt @@ -35,10 +35,13 @@ import app.passwordstore.R import app.passwordstore.crypto.GpgIdentifier import app.passwordstore.ui.compose.theme.APSThemePreview import app.passwordstore.util.extensions.conditional +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.toPersistentList @Composable fun KeyList( - identifiers: List<GpgIdentifier>, + identifiers: ImmutableList<GpgIdentifier>, onItemClick: (identifier: GpgIdentifier) -> Unit, modifier: Modifier = Modifier, onKeySelected: ((identifier: GpgIdentifier) -> Unit)? = null, @@ -141,9 +144,10 @@ private fun KeyListPreview() { KeyList( identifiers = listOfNotNull( - GpgIdentifier.fromString("ultramicroscopicsilicovolcanoconiosis@example.com"), - GpgIdentifier.fromString("0xB950AE2813841585"), - ), + GpgIdentifier.fromString("ultramicroscopicsilicovolcanoconiosis@example.com"), + GpgIdentifier.fromString("0xB950AE2813841585"), + ) + .toPersistentList(), onItemClick = {} ) } @@ -155,7 +159,7 @@ private fun KeyListPreview() { fun EmptyKeyListPreview() { APSThemePreview { Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) { - KeyList(identifiers = emptyList(), onItemClick = {}) + KeyList(identifiers = persistentListOf(), onItemClick = {}) } } } diff --git a/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt b/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt index a21a6962..a08b41fa 100644 --- a/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt +++ b/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt @@ -13,11 +13,14 @@ import com.github.michaelbull.result.Ok import com.github.michaelbull.result.map import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.launch @HiltViewModel class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyManager) : ViewModel() { - var keys: List<GpgIdentifier> by mutableStateOf(emptyList()) + var keys: ImmutableList<GpgIdentifier> by mutableStateOf(persistentListOf()) init { updateKeySet() @@ -31,7 +34,7 @@ class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyMana keys.mapNotNull { key -> KeyUtils.tryGetEmail(key) } } ) { - is Ok -> keys = result.value + is Ok -> keys = result.value.toPersistentList() is Err -> TODO() } } |