From 6608d29fa04d339c6ba71b6d32710d68ed8efd17 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 26 Sep 2025 12:10:41 +0200 Subject: [PATCH] Cleanup to be able to merge. --- .../space/impl/leave/LeaveSpacePresenter.kt | 23 +++++-------------- .../features/space/impl/root/SpaceView.kt | 5 +++- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpacePresenter.kt b/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpacePresenter.kt index 59713f2f82..810b73cffd 100644 --- a/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpacePresenter.kt +++ b/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/leave/LeaveSpacePresenter.kt @@ -25,18 +25,17 @@ import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.architecture.runUpdatingState import io.element.android.libraries.matrix.api.MatrixClient import io.element.android.libraries.matrix.api.core.RoomId -import io.element.android.libraries.previewutils.room.aSpaceRoom +import io.element.android.libraries.matrix.api.spaces.SpaceRoom import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlin.jvm.optionals.getOrNull @Inject class LeaveSpacePresenter( @Assisted private val inputs: SpaceEntryPoint.Inputs, - private val matrixClient: MatrixClient, + matrixClient: MatrixClient, ) : Presenter { @AssistedFactory fun interface Factory { @@ -57,14 +56,7 @@ class LeaveSpacePresenter( } val joinedSpaceRooms by produceState(emptyList()) { // TODO Get the joined room from the SDK, should also have the - val rooms = listOf( - aSpaceRoom( - roomId = RoomId("!roomId1:example.com"), - ), - aSpaceRoom( - roomId = RoomId("!roomId2:example.com"), - ), - ) + val rooms = emptyList() // By default select all rooms selectedRoomIds.value = rooms.map { it.roomId }.toSet() value = rooms @@ -77,10 +69,10 @@ class LeaveSpacePresenter( value = AsyncData.Success( joinedSpaceRooms.map { SelectableSpaceRoom( - it, + spaceRoom = it, // TODO Get this value from the SDK isLastAdmin = false, - selectedRoomIds.value.contains(it.roomId), + isSelected = selectedRoomIds.value.contains(it.roomId), ) }.toPersistentList() ) @@ -130,10 +122,7 @@ class LeaveSpacePresenter( ) = launch { runUpdatingState(leaveSpaceAction) { // TODO SDK API call to leave all the rooms and space - delay(1000) - val room = matrixClient.getRoom(inputs.roomId) - ?: return@runUpdatingState Result.failure(Exception("Room not found")) - room.leave() + Result.failure(Exception("Not implemented")) } } } diff --git a/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/root/SpaceView.kt b/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/root/SpaceView.kt index e8d5a8f2c3..2f9e4ac291 100644 --- a/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/root/SpaceView.kt +++ b/features/space/impl/src/main/kotlin/io/element/android/features/space/impl/root/SpaceView.kt @@ -157,7 +157,7 @@ private fun LoadingMoreIndicator( private fun SpaceViewTopBar( state: SpaceState, onBackClick: () -> Unit, - onLeaveSpaceClick: () -> Unit, + @Suppress("unused") onLeaveSpaceClick: () -> Unit, onShareSpace: () -> Unit, modifier: Modifier = Modifier, ) { @@ -203,6 +203,8 @@ private fun SpaceViewTopBar( ) } ) + /* + // TODO re-enable when we have SDK APIs to leave a space DropdownMenuItem( onClick = { showMenu = false @@ -217,6 +219,7 @@ private fun SpaceViewTopBar( ) } ) + */ } }, )