mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Accept space invites from a home screen cell. (#4554)
* Push the SpaceScreen after accepting an invite from the room list. * Add a test for accepting a space invite.
This commit is contained in:
@@ -23,6 +23,7 @@ enum HomeScreenCoordinatorAction {
|
||||
case presentRoomDetails(roomIdentifier: String)
|
||||
case presentReportRoom(roomIdentifier: String)
|
||||
case presentDeclineAndBlock(userID: String, roomID: String)
|
||||
case presentSpace(SpaceRoomListProxyProtocol)
|
||||
case roomLeft(roomIdentifier: String)
|
||||
case transferOwnership(roomIdentifier: String)
|
||||
case presentSettingsScreen
|
||||
@@ -67,6 +68,10 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.presentRoomDetails(roomIdentifier: roomIdentifier))
|
||||
case .presentReportRoom(let roomIdentifier):
|
||||
actionsSubject.send(.presentReportRoom(roomIdentifier: roomIdentifier))
|
||||
case .presentDeclineAndBlock(let userID, let roomID):
|
||||
actionsSubject.send(.presentDeclineAndBlock(userID: userID, roomID: roomID))
|
||||
case .presentSpace(let spaceRoomListProxy):
|
||||
actionsSubject.send(.presentSpace(spaceRoomListProxy))
|
||||
case .roomLeft(roomIdentifier: let roomIdentifier):
|
||||
actionsSubject.send(.roomLeft(roomIdentifier: roomIdentifier))
|
||||
case .presentFeedbackScreen:
|
||||
@@ -85,8 +90,6 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.presentGlobalSearch)
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
case .presentDeclineAndBlock(let userID, let roomID):
|
||||
actionsSubject.send(.presentDeclineAndBlock(userID: userID, roomID: roomID))
|
||||
case .transferOwnership(let roomIdentifier):
|
||||
actionsSubject.send(.transferOwnership(roomIdentifier: roomIdentifier))
|
||||
}
|
||||
|
||||
@@ -9,11 +9,12 @@ import Combine
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
enum HomeScreenViewModelAction: Equatable {
|
||||
enum HomeScreenViewModelAction {
|
||||
case presentRoom(roomIdentifier: String)
|
||||
case presentRoomDetails(roomIdentifier: String)
|
||||
case presentReportRoom(roomIdentifier: String)
|
||||
case presentDeclineAndBlock(userID: String, roomID: String)
|
||||
case presentSpace(SpaceRoomListProxyProtocol)
|
||||
case roomLeft(roomIdentifier: String)
|
||||
case transferOwnership(roomIdentifier: String)
|
||||
case presentSecureBackupSettings
|
||||
|
||||
@@ -414,11 +414,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
|
||||
switch await userSession.clientProxy.joinRoom(roomID, via: []) {
|
||||
case .success:
|
||||
actionsSubject.send(.presentRoom(roomIdentifier: roomID))
|
||||
analyticsService.trackJoinedRoom(isDM: roomProxy.info.isDirect,
|
||||
isSpace: roomProxy.info.isSpace,
|
||||
activeMemberCount: UInt(roomProxy.info.activeMembersCount))
|
||||
appSettings.seenInvites.remove(roomID)
|
||||
await finishAcceptInvite(roomProxy: roomProxy)
|
||||
case .failure(let error):
|
||||
switch error {
|
||||
case .invalidInvite:
|
||||
@@ -429,6 +425,28 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
}
|
||||
}
|
||||
|
||||
private func finishAcceptInvite(roomProxy: InvitedRoomProxyProtocol) async {
|
||||
if roomProxy.info.isSpace {
|
||||
let spaceService = userSession.clientProxy.spaceService
|
||||
|
||||
switch await spaceService.spaceRoomList(spaceID: roomProxy.id, parent: nil) {
|
||||
case .success(let spaceRoomListProxy):
|
||||
actionsSubject.send(.presentSpace(spaceRoomListProxy))
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed to get the space room list after accepting invite: \(error)")
|
||||
displayError()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
actionsSubject.send(.presentRoom(roomIdentifier: roomProxy.id))
|
||||
}
|
||||
|
||||
analyticsService.trackJoinedRoom(isDM: roomProxy.info.isDirect,
|
||||
isSpace: roomProxy.info.isSpace,
|
||||
activeMemberCount: UInt(roomProxy.info.activeMembersCount))
|
||||
appSettings.seenInvites.remove(roomProxy.id)
|
||||
}
|
||||
|
||||
private func showDeclineInviteConfirmationAlert(roomID: String) async {
|
||||
guard let room = state.rooms.first(where: { $0.id == roomID }) else {
|
||||
displayError()
|
||||
|
||||
Reference in New Issue
Block a user