Implemented adding the room to the space after selection, and the editableSpace proxied API. Also updated and added tests.

This commit is contained in:
Mauro Romito
2026-01-21 14:58:03 +01:00
committed by Mauro
parent 07243be949
commit 9dead7ed55
50 changed files with 406 additions and 83 deletions
@@ -61,11 +61,16 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
isKnockingFeatureEnabled: appSettings.knockingEnabled,
canSelectSpace: canSelectSpace,
aliasLocalPart: roomAliasNameFromRoomDisplayName(roomName: ""),
topLevelSpaces: canSelectSpace ? userSession.clientProxy.spaceService.topLevelSpacesPublisher.value : [],
bindings: bindings),
mediaProvider: userSession.mediaProvider)
setupBindings()
if canSelectSpace {
Task {
state.editableSpaces = await userSession.clientProxy.spaceService.editableSpaces()
}
}
}
// MARK: - Public
@@ -195,15 +200,6 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
}
}
.store(in: &cancellables)
if state.canSelectSpace {
userSession
.clientProxy
.spaceService
.topLevelSpacesPublisher
.weakAssign(to: \.state.topLevelSpaces, on: self)
.store(in: &cancellables)
}
}
private func createRoom() async {
@@ -277,15 +273,21 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
var spaceRoomListProxy: SpaceRoomListProxyProtocol?
if state.isSpace {
switch await userSession.clientProxy.spaceService.spaceRoomList(spaceID: roomProxy.id) {
switch await userSession.clientProxy.spaceService.spaceRoomList(spaceID: roomID) {
case .success(let value):
spaceRoomListProxy = value
case .failure:
MXLog.error("Failed to get space room list for newly created space with id: \(roomProxy.id)")
MXLog.error("Failed to get space room list for newly created space with id: \(roomID)")
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
}
}
if let selectedSpace = state.bindings.selectedSpace,
case .failure = await userSession.clientProxy.spaceService.addChild(roomID, to: selectedSpace.id) {
MXLog.error("Failed to add the created room with id: \(roomID) to the space with id: \(selectedSpace.id)")
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
}
actionsSubject.send(.createdRoom(roomProxy, spaceRoomListProxy))
case .failure:
state.bindings.alertInfo = AlertInfo(id: .failedCreatingRoom,