Added a delayed loading when opening a room (#3748)

* added a delayed loader

* fixed an issue where the loading was not stopped

* pr suggestions
This commit is contained in:
Mauro 2025-02-06 17:55:46 +01:00 committed by GitHub
parent b900eec5a2
commit 7560f2c5f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 {