Skip to content

Commit

Permalink
Correctly move to the no room selected state when popping in compact …
Browse files Browse the repository at this point in the history
…layouts
  • Loading branch information
stefanceriu committed Dec 7, 2022
1 parent 10bf2ad commit 1467b0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,16 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
let coordinator = RoomScreenCoordinator(parameters: parameters)

detailStackScreenCoordinator.setRootCoordinator(coordinator)
splitScreenCoordinator.setDetailCoordinator(detailStackScreenCoordinator) { [weak self] in
self?.stateMachine.processEvent(.deselectRoom)
splitScreenCoordinator.setDetailCoordinator(detailStackScreenCoordinator) { [weak self, roomIdentifier] in
guard let self else { return }

// Move the state machine to no room selected if the room currently being dimissed
// is the same as the one selected in the state machine.
// This generally happens when popping the room screen while in a compact layout
if case let .roomList(selectedRoomId) = self.stateMachine.state, selectedRoomId == roomIdentifier {
self.stateMachine.processEvent(.deselectRoom)
self.detailStackScreenCoordinator.setRootCoordinator(nil)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class UserSessionFlowCoordinatorStateMachine {

private let stateMachine: StateMachine<State, Event>

var state: UserSessionFlowCoordinatorStateMachine.State {
stateMachine.state
}

init() {
stateMachine = StateMachine(state: .initial)
configure()
Expand Down

0 comments on commit 1467b0a

Please sign in to comment.