Add the JoinRoomScreen into the SpaceFlowCoordinator. (#4513)

* Add the JoinRoomScreen into the SpaceFlowCoordinator.

The screen needs further work to make the join work.

* Fix the tests completing the join flow with the right action.
This commit is contained in:
Doug
2025-09-17 15:12:45 +01:00
committed by GitHub
parent c4de609ad7
commit 27f4c25194
22 changed files with 260 additions and 92 deletions
@@ -20,6 +20,7 @@ struct SpaceScreenCoordinatorParameters {
enum SpaceScreenCoordinatorAction {
case selectSpace(SpaceRoomListProxyProtocol)
case selectUnjoinedSpace(SpaceRoomProxyProtocol)
case selectRoom(roomID: String)
}
@@ -52,6 +53,8 @@ final class SpaceScreenCoordinator: CoordinatorProtocol {
switch action {
case .selectSpace(let spaceRoomListProxy):
actionsSubject.send(.selectSpace(spaceRoomListProxy))
case .selectUnjoinedSpace(let spaceRoomProxy):
actionsSubject.send(.selectUnjoinedSpace(spaceRoomProxy))
case .selectRoom(let roomID):
actionsSubject.send(.selectRoom(roomID: roomID))
}
@@ -9,6 +9,7 @@ import Foundation
enum SpaceScreenViewModelAction {
case selectSpace(SpaceRoomListProxyProtocol)
case selectUnjoinedSpace(SpaceRoomProxyProtocol)
case selectRoom(roomID: String)
}
@@ -68,7 +68,11 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
switch viewAction {
case .spaceAction(.select(let spaceRoomProxy)):
if spaceRoomProxy.isSpace {
Task { await selectSpace(spaceRoomProxy) }
if spaceRoomProxy.state != .joined {
actionsSubject.send(.selectUnjoinedSpace(spaceRoomProxy))
} else {
Task { await selectSpace(spaceRoomProxy) }
}
} else {
// No need to check the join state, the room flow will show an appropriately configured join screen if needed.
actionsSubject.send(.selectRoom(roomID: spaceRoomProxy.id))
@@ -85,16 +89,6 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
// MARK: - Private
private func selectSpace(_ spaceRoomProxy: SpaceRoomProxyProtocol) async {
switch await spaceServiceProxy.spaceRoomList(for: spaceRoomProxy) {
case .success(let spaceRoomListProxy):
actionsSubject.send(.selectSpace(spaceRoomListProxy))
case .failure(let error):
MXLog.error("Unable to select space: \(error)")
showFailureIndicator()
}
}
private func join(_ spaceRoomProxy: SpaceRoomProxyProtocol) async {
state.joiningRoomIDs.insert(spaceRoomProxy.id)
defer { state.joiningRoomIDs.remove(spaceRoomProxy.id) }
@@ -114,6 +108,16 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
}
}
private func selectSpace(_ spaceRoomProxy: SpaceRoomProxyProtocol) async {
switch await spaceServiceProxy.spaceRoomList(spaceID: spaceRoomProxy.id) {
case .success(let spaceRoomListProxy):
actionsSubject.send(.selectSpace(spaceRoomListProxy))
case .failure(let error):
MXLog.error("Unable to select space: \(error)")
showFailureIndicator()
}
}
// MARK: - Indicators
private static var failureIndicatorID: String { "\(Self.self)-Failure" }