summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-06-15 14:02:05 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-06-15 14:21:49 +0530
commit26a7298978a42cd7b8b2987c60edd602124edc5c (patch)
treea69cb2ece76696838617eb2861766499a219de7f /app/src/main/java
parenta00bd046b6794d97bbff47d81054450db0c447fb (diff)
fix: address `ComposeUnstableCollections` lint
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt14
-rw-r--r--app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt7
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()
}
}