Observe room info updates and automatically dismiss the room if meanwhile left or banned (#4122)

* Fix #3302 - Observe room info updates and automatically dismiss the room if meanwhile left or banned.
This commit is contained in:
Stefan Ceriu
2025-05-16 12:55:33 +03:00
committed by GitHub
parent f5089e8d81
commit 35f615ddd1
3 changed files with 42 additions and 1 deletions
@@ -273,6 +273,19 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
// early return above could result in trying to access the room's timeline provider
// before it has been set which triggers a fatal error.
self.roomProxy = roomProxy
// Subscribe to room info updates in order to detect rooms being left on other devices
// and react accordingly by dismissing this flow coordinator.
self.roomProxy.infoPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] info in
guard let self else { return }
if info.membership == .left || info.membership == .banned, stateMachine.state != .complete {
stateMachine.tryEvent(.dismissFlow)
}
}
.store(in: &cancellables)
}
// swiftlint:disable:next function_body_length