reused the room details view model for the space settings screen

This commit is contained in:
Mauro Romito
2025-10-31 14:23:08 +01:00
committed by Mauro
parent dc9ab56972
commit e59870b1e7
11 changed files with 103 additions and 222 deletions
@@ -169,6 +169,11 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
// MARK: - Private
private func processTapToLeave() {
guard !roomProxy.infoPublisher.value.isSpace else {
Task { await processLeaveSpace() }
return
}
guard state.joinedMembersCount > 1 else {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomID: roomProxy.id,
isDM: roomProxy.isDirectOneToOneRoom,
@@ -202,6 +207,16 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
state: roomProxy.infoPublisher.value.isPrivate ?? true ? .private : .public)
}
private func processLeaveSpace() async {
switch await userSession.clientProxy.spaceService.leaveSpace(spaceID: roomProxy.id) {
case .success:
// TODO: Handle leave space
break
case .failure(let failure):
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
}
}
private func setupRoomSubscription() {
roomProxy.infoPublisher
.receive(on: DispatchQueue.main)