Add Konsist test to check that toPersistentList() is not used.
Same for `toPersistentSet()` and `toPersistentMap()`. Fix existing issues.
This commit is contained in:
parent
2fa1b9d448
commit
67c9daa0bf
85 changed files with 305 additions and 254 deletions
|
|
@ -15,8 +15,9 @@ import io.element.android.libraries.architecture.Presenter
|
|||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import io.element.android.libraries.sessionstorage.api.SessionStore
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@Inject
|
||||
class AccountSelectPresenter(
|
||||
|
|
@ -24,7 +25,7 @@ class AccountSelectPresenter(
|
|||
) : Presenter<AccountSelectState> {
|
||||
@Composable
|
||||
override fun present(): AccountSelectState {
|
||||
val accounts by produceState(persistentListOf()) {
|
||||
val accounts by produceState<ImmutableList<MatrixUser>>(persistentListOf()) {
|
||||
// Do not use sessionStore.sessionsFlow() to not make it change when an account is selected.
|
||||
value = sessionStore.getAllSessions()
|
||||
.map {
|
||||
|
|
@ -34,7 +35,7 @@ class AccountSelectPresenter(
|
|||
avatarUrl = it.userAvatarUrl,
|
||||
)
|
||||
}
|
||||
.toPersistentList()
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
return AccountSelectState(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ package io.element.android.libraries.accountselect.impl
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import io.element.android.libraries.matrix.ui.components.aMatrixUserList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
open class AccountSelectStateProvider : PreviewParameterProvider<AccountSelectState> {
|
||||
override val values: Sequence<AccountSelectState>
|
||||
|
|
@ -23,5 +23,5 @@ open class AccountSelectStateProvider : PreviewParameterProvider<AccountSelectSt
|
|||
private fun anAccountSelectState(
|
||||
accounts: List<MatrixUser> = listOf(),
|
||||
) = AccountSelectState(
|
||||
accounts = accounts.toPersistentList(),
|
||||
accounts = accounts.toImmutableList(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue