Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a delayed loading when opening a room #3748

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1618,6 +1620,16 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {

flowCoordinator.start()
}

private static let loadingIndicatorID = "RoomFlowCoordinator.loadingIndicator"
Velin92 marked this conversation as resolved.
Show resolved Hide resolved

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)
Velin92 marked this conversation as resolved.
Show resolved Hide resolved
}

private func hideLoadingIndicator() {
userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorID)
}
}

private extension RoomFlowCoordinator {
Expand Down
Loading