Make AboutState stable

This commit is contained in:
Benoit Marty
2025-10-09 17:00:54 +02:00
committed by Benoit Marty
parent fe51f65aff
commit cd31ff0f9f
3 changed files with 9 additions and 4 deletions
@@ -7,6 +7,8 @@
package io.element.android.features.preferences.impl.about package io.element.android.features.preferences.impl.about
import kotlinx.collections.immutable.ImmutableList
data class AboutState( data class AboutState(
val elementLegals: List<ElementLegal>, val elementLegals: ImmutableList<ElementLegal>,
) )
@@ -8,6 +8,7 @@
package io.element.android.features.preferences.impl.about package io.element.android.features.preferences.impl.about
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import kotlinx.collections.immutable.toImmutableList
open class AboutStateProvider : PreviewParameterProvider<AboutState> { open class AboutStateProvider : PreviewParameterProvider<AboutState> {
override val values: Sequence<AboutState> override val values: Sequence<AboutState>
@@ -19,5 +20,5 @@ open class AboutStateProvider : PreviewParameterProvider<AboutState> {
fun anAboutState( fun anAboutState(
elementLegals: List<ElementLegal> = getAllLegals(), elementLegals: List<ElementLegal> = getAllLegals(),
) = AboutState( ) = AboutState(
elementLegals = elementLegals, elementLegals = elementLegals.toImmutableList(),
) )
@@ -10,6 +10,8 @@ package io.element.android.features.preferences.impl.about
import androidx.annotation.StringRes import androidx.annotation.StringRes
import io.element.android.features.preferences.impl.BuildConfig import io.element.android.features.preferences.impl.BuildConfig
import io.element.android.libraries.ui.strings.CommonStrings import io.element.android.libraries.ui.strings.CommonStrings
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
private const val COPYRIGHT_URL = BuildConfig.URL_COPYRIGHT private const val COPYRIGHT_URL = BuildConfig.URL_COPYRIGHT
private const val USE_POLICY_URL = BuildConfig.URL_ACCEPTABLE_USE private const val USE_POLICY_URL = BuildConfig.URL_ACCEPTABLE_USE
@@ -24,8 +26,8 @@ sealed class ElementLegal(
data object PrivacyPolicy : ElementLegal(CommonStrings.common_privacy_policy, PRIVACY_URL) data object PrivacyPolicy : ElementLegal(CommonStrings.common_privacy_policy, PRIVACY_URL)
} }
fun getAllLegals(): List<ElementLegal> { fun getAllLegals(): ImmutableList<ElementLegal> {
return listOf( return persistentListOf(
ElementLegal.Copyright, ElementLegal.Copyright,
ElementLegal.AcceptableUsePolicy, ElementLegal.AcceptableUsePolicy,
ElementLegal.PrivacyPolicy, ElementLegal.PrivacyPolicy,