Make AboutState stable

This commit is contained in:
Benoit Marty
2025-10-09 17:00:54 +02:00
committed by Benoit Marty
parent 0f1ae41b41
commit f6eed21055
3 changed files with 9 additions and 4 deletions

View File

@@ -7,6 +7,8 @@
package io.element.android.features.preferences.impl.about
import kotlinx.collections.immutable.ImmutableList
data class AboutState(
val elementLegals: List<ElementLegal>,
val elementLegals: ImmutableList<ElementLegal>,
)

View File

@@ -8,6 +8,7 @@
package io.element.android.features.preferences.impl.about
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import kotlinx.collections.immutable.toImmutableList
open class AboutStateProvider : PreviewParameterProvider<AboutState> {
override val values: Sequence<AboutState>
@@ -19,5 +20,5 @@ open class AboutStateProvider : PreviewParameterProvider<AboutState> {
fun anAboutState(
elementLegals: List<ElementLegal> = getAllLegals(),
) = AboutState(
elementLegals = elementLegals,
elementLegals = elementLegals.toImmutableList(),
)

View File

@@ -10,6 +10,8 @@ package io.element.android.features.preferences.impl.about
import androidx.annotation.StringRes
import io.element.android.features.preferences.impl.BuildConfig
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 USE_POLICY_URL = BuildConfig.URL_ACCEPTABLE_USE
@@ -24,8 +26,8 @@ sealed class ElementLegal(
data object PrivacyPolicy : ElementLegal(CommonStrings.common_privacy_policy, PRIVACY_URL)
}
fun getAllLegals(): List<ElementLegal> {
return listOf(
fun getAllLegals(): ImmutableList<ElementLegal> {
return persistentListOf(
ElementLegal.Copyright,
ElementLegal.AcceptableUsePolicy,
ElementLegal.PrivacyPolicy,