Cleanup to be able to merge.

This commit is contained in:
Benoit Marty
2025-09-26 12:10:41 +02:00
committed by Benoit Marty
parent 3c64eeb1c4
commit 6608d29fa0
2 changed files with 10 additions and 18 deletions

View File

@@ -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<LeaveSpaceState> {
@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<SpaceRoom>()
// 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"))
}
}
}

View File

@@ -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(
)
}
)
*/
}
},
)