mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
pr suggestions
This commit is contained in:
@@ -177,7 +177,7 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
rolesAndPermissionsFlowCoordinator?.clearRoute(animated: animated)
|
rolesAndPermissionsFlowCoordinator?.clearRoute(animated: animated)
|
||||||
clearRoute(animated: animated) // Re-run with the state machine back in the .space state.
|
clearRoute(animated: animated) // Re-run with the state machine back in the .space state.
|
||||||
case .createChildRoomFlow:
|
case .createChildRoomFlow:
|
||||||
createChildRoomFlowCoordinator?.clearRoute(animated: animated)
|
navigationStackCoordinator.setSheetCoordinator(nil)
|
||||||
clearRoute(animated: animated) // Re-run with the state machine back in the .space state.
|
clearRoute(animated: animated) // Re-run with the state machine back in the .space state.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class SpacesTabFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .initial, .spacesScreen:
|
case .initial, .spacesScreen:
|
||||||
break
|
break
|
||||||
case .createSpaceFlow:
|
case .createSpaceFlow:
|
||||||
startChatFlowCoordinator?.clearRoute(animated: animated)
|
navigationSplitCoordinator.setSheetCoordinator(nil)
|
||||||
clearRoute(animated: animated)
|
clearRoute(animated: animated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ class StartChatFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
enum Event: EventType {
|
enum Event: EventType {
|
||||||
/// The flow is being started.
|
/// The flow is being started.
|
||||||
case start
|
case start
|
||||||
|
|
||||||
/// The user would like to create a room.
|
/// The user would like to create a room.
|
||||||
case createRoom
|
case createRoom(isSpace: Bool)
|
||||||
/// The user dismissed the create room screen.
|
/// The user dismissed the create room screen.
|
||||||
case dismissedCreateRoom
|
case dismissedCreateRoom
|
||||||
|
|
||||||
@@ -97,7 +96,14 @@ class StartChatFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func start(animated: Bool) {
|
func start(animated: Bool) {
|
||||||
|
switch entryPoint {
|
||||||
|
case .startChat:
|
||||||
stateMachine.tryEvent(.start)
|
stateMachine.tryEvent(.start)
|
||||||
|
case .createSpace:
|
||||||
|
stateMachine.tryEvent(.createRoom(isSpace: true))
|
||||||
|
case .createRoomInSpace(let space):
|
||||||
|
stateMachine.tryEvent(.createRoom(isSpace: false), userInfo: space)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
||||||
@@ -127,28 +133,22 @@ class StartChatFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func configureStateMachine() {
|
private func configureStateMachine() {
|
||||||
stateMachine.addRouteMapping { [weak self] event, fromState, _ in
|
stateMachine.addRoutes(event: .start, transitions: [.initial => .startChat]) { [weak self] _ in
|
||||||
guard let self, event == .start, fromState == .initial else { return nil }
|
self?.presentStartChatScreen()
|
||||||
switch entryPoint {
|
|
||||||
case .startChat:
|
|
||||||
return .startChat
|
|
||||||
case .createSpace, .createRoomInSpace:
|
|
||||||
return .createRoom
|
|
||||||
}
|
}
|
||||||
} handler: { [weak self] _ in
|
stateMachine.addRoutes(event: .createRoom(isSpace: true), transitions: [.initial => .createRoom]) { [weak self] _ in
|
||||||
guard let self else { return }
|
self?.presentCreateRoomScreen(isSpace: true, spaceSelectionMode: nil, isRoot: true)
|
||||||
switch entryPoint {
|
|
||||||
case .startChat:
|
|
||||||
presentStartChatScreen()
|
|
||||||
case .createSpace:
|
|
||||||
presentCreateRoomScreen(isSpace: true, spaceSelectionMode: nil, isRoot: true)
|
|
||||||
case .createRoomInSpace(let space):
|
|
||||||
presentCreateRoomScreen(isSpace: false, spaceSelectionMode: .preSelected(space), isRoot: true)
|
|
||||||
}
|
}
|
||||||
|
stateMachine.addRoutes(event: .createRoom(isSpace: false), transitions: [.initial => .createRoom]) { [weak self] context in
|
||||||
|
guard context.fromState == .initial else { return } // Required check because the event is used in another route.
|
||||||
|
guard let space = context.userInfo as? SpaceServiceRoomProtocol else {
|
||||||
|
fatalError("This transition only supports creating a room in a pre-selected space.")
|
||||||
|
}
|
||||||
|
self?.presentCreateRoomScreen(isSpace: false, spaceSelectionMode: .preSelected(space), isRoot: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
stateMachine.addRoutes(event: .createRoom, transitions: [.startChat => .createRoom]) { [weak self] _ in
|
stateMachine.addRoutes(event: .createRoom(isSpace: false), transitions: [.startChat => .createRoom]) { [weak self] context in
|
||||||
guard let self else { return }
|
guard let self, context.fromState == .startChat else { return } // Required check because the event is used in another route.
|
||||||
presentCreateRoomScreen(isSpace: false,
|
presentCreateRoomScreen(isSpace: false,
|
||||||
spaceSelectionMode: flowParameters.appSettings.createSpaceEnabled ? .editableSpacesList : nil,
|
spaceSelectionMode: flowParameters.appSettings.createSpaceEnabled ? .editableSpacesList : nil,
|
||||||
isRoot: false)
|
isRoot: false)
|
||||||
@@ -195,7 +195,7 @@ class StartChatFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .close:
|
case .close:
|
||||||
actionsSubject.send(.finished(.cancelled))
|
actionsSubject.send(.finished(.cancelled))
|
||||||
case .createRoom:
|
case .createRoom:
|
||||||
stateMachine.tryEvent(.createRoom)
|
stateMachine.tryEvent(.createRoom(isSpace: false))
|
||||||
case .openRoom(let roomID):
|
case .openRoom(let roomID):
|
||||||
actionsSubject.send(.finished(.room(id: roomID)))
|
actionsSubject.send(.finished(.room(id: roomID)))
|
||||||
case .openRoomDirectorySearch:
|
case .openRoomDirectorySearch:
|
||||||
|
|||||||
Reference in New Issue
Block a user