From 26a7298978a42cd7b8b2987c60edd602124edc5c Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 15 Jun 2023 14:02:05 +0530 Subject: fix: address `ComposeUnstableCollections` lint --- app/build.gradle.kts | 1 + app/lint-baseline.xml | 15 ++------------- app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt | 14 +++++++++----- .../passwordstore/util/viewmodel/PGPKeyListViewModel.kt | 7 +++++-- 4 files changed, 17 insertions(+), 20 deletions(-) (limited to 'app') diff --git a/app/build.gradle.kts b/app/build.gradle.kts index aacca7a5..5ba7b7a0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -71,6 +71,7 @@ dependencies { implementation(libs.compose.ui.tooling) implementation(libs.dagger.hilt.android) + implementation(libs.kotlinx.collections.immutable) implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlinx.coroutines.core) diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index de1f0a60..5ccbd208 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,5 +1,5 @@ - + @@ -227,17 +227,6 @@ column="4"/> - - - - , + identifiers: ImmutableList, 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 by mutableStateOf(emptyList()) + var keys: ImmutableList 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() } } -- cgit v1.2.3