diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index d7959de42..4b3c1acfa 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -229,6 +229,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { private func handleRoomRoute(roomID: String, via: [String], presentationAction: PresentationAction? = nil, animated: Bool) async { guard roomID == self.roomID else { fatalError("Navigation route doesn't belong to this room flow.") } + showLoadingIndicator(delay: .milliseconds(250)) + defer { hideLoadingIndicator() } guard let room = await userSession.clientProxy.roomForIdentifier(roomID) else { stateMachine.tryEvent(.presentJoinRoomScreen(via: via), userInfo: EventUserInfo(animated: animated)) return @@ -1618,6 +1620,21 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { flowCoordinator.start() } + + private static let loadingIndicatorID = "\(RoomFlowCoordinator.self)-Loading" + + private func showLoadingIndicator(delay: Duration? = nil) { + userIndicatorController.submitIndicator(.init(id: Self.loadingIndicatorID, + type: .modal(progress: .indeterminate, + interactiveDismissDisabled: false, + allowsInteraction: false), + title: L10n.commonLoading, persistent: true), + delay: delay) + } + + private func hideLoadingIndicator() { + userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorID) + } } private extension RoomFlowCoordinator {