From c5848426111ed08a2722f812fe67c60ab6aeac33 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 9 Oct 2025 17:25:25 +0200 Subject: [PATCH] Make LeaveSpaceState stable --- .../features/space/impl/leave/LeaveSpaceState.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpaceState.kt b/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpaceState.kt index 0f2a0f93f6..0f0cf143b1 100644 --- a/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpaceState.kt +++ b/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpaceState.kt @@ -10,6 +10,7 @@ package io.element.android.features.space.impl.leave import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.architecture.AsyncData import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toImmutableList data class LeaveSpaceState( val spaceName: String?, @@ -18,10 +19,15 @@ data class LeaveSpaceState( val leaveSpaceAction: AsyncAction, val eventSink: (LeaveSpaceEvents) -> Unit, ) { - private val rooms = selectableSpaceRooms.dataOrNull().orEmpty() - private val partition = rooms.partition { it.isLastAdmin } - private val lastAdminRooms = partition.first - private val selectableRooms = partition.second + private val rooms = selectableSpaceRooms.dataOrNull().orEmpty().toImmutableList() + private val lastAdminRooms: ImmutableList + private val selectableRooms: ImmutableList + + init { + val partition = rooms.partition { it.isLastAdmin } + lastAdminRooms = partition.first.toImmutableList() + selectableRooms = partition.second.toImmutableList() + } /** * True if we should show the quick action to select/deselect all rooms.