mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Add support for quick room search through the Cmd+K shortcut (#2363)
This commit is contained in:
@@ -978,7 +978,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func presentMessageForwarding(for itemID: TimelineItemIdentifier) {
|
||||
guard let roomProxy, let roomSummaryProvider = userSession.clientProxy.messageForwardingRoomSummaryProvider, let eventID = itemID.eventID else {
|
||||
guard let roomProxy, let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider, let eventID = itemID.eventID else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
@@ -1002,7 +1002,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
await self.forward(eventID: eventID, toRoomID: roomID)
|
||||
}
|
||||
}
|
||||
}.store(in: &cancellables)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
stackCoordinator.setRootCoordinator(coordinator)
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ enum UserSessionFlowCoordinatorAction {
|
||||
}
|
||||
|
||||
class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let windowManager: WindowManagerProtocol
|
||||
private let userSession: UserSessionProtocol
|
||||
private let navigationSplitCoordinator: NavigationSplitCoordinator
|
||||
private let windowManager: WindowManagerProtocol
|
||||
private let bugReportService: BugReportServiceProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let actionsSubject: PassthroughSubject<UserSessionFlowCoordinatorAction, Never> = .init()
|
||||
@@ -41,6 +41,9 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
// periphery:ignore - retaining purpose
|
||||
private var bugReportFlowCoordinator: BugReportFlowCoordinator?
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
private var globalSearchScreenCoordinator: GlobalSearchScreenCoordinator?
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private let sidebarNavigationStackCoordinator: NavigationStackCoordinator
|
||||
@@ -63,9 +66,9 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine = UserSessionFlowCoordinatorStateMachine()
|
||||
self.userSession = userSession
|
||||
self.navigationSplitCoordinator = navigationSplitCoordinator
|
||||
self.windowManager = windowManager
|
||||
self.bugReportService = bugReportService
|
||||
self.appSettings = appSettings
|
||||
self.windowManager = windowManager
|
||||
|
||||
sidebarNavigationStackCoordinator = NavigationStackCoordinator(navigationSplitCoordinator: navigationSplitCoordinator)
|
||||
detailNavigationStackCoordinator = NavigationStackCoordinator(navigationSplitCoordinator: navigationSplitCoordinator)
|
||||
@@ -331,6 +334,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
Task { await self.runLogoutFlow() }
|
||||
case .presentInvitesScreen:
|
||||
stateMachine.processEvent(.showInvitesScreen)
|
||||
case .presentGlobalSearch:
|
||||
presentGlobalSearch()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
@@ -528,4 +533,44 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
navigationSplitCoordinator.setSheetCoordinator(coordinator, animated: true)
|
||||
}
|
||||
|
||||
// MARK: Global search
|
||||
|
||||
private func presentGlobalSearch() {
|
||||
guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else {
|
||||
fatalError("Global search room summary provider unavailable")
|
||||
}
|
||||
|
||||
let coordinator = GlobalSearchScreenCoordinator(parameters: .init(roomSummaryProvider: roomSummaryProvider,
|
||||
mediaProvider: userSession.mediaProvider))
|
||||
|
||||
globalSearchScreenCoordinator = coordinator
|
||||
|
||||
coordinator.actions
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
switch action {
|
||||
case .dismiss:
|
||||
dismissGlobalSearch()
|
||||
case .select(let roomID):
|
||||
dismissGlobalSearch()
|
||||
handleAppRoute(.room(roomID: roomID), animated: true)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
let hostingController = UIHostingController(rootView: coordinator.toPresentable())
|
||||
hostingController.view.backgroundColor = .clear
|
||||
windowManager.globalSearchWindow.rootViewController = hostingController
|
||||
|
||||
windowManager.showGlobalSearch()
|
||||
}
|
||||
|
||||
private func dismissGlobalSearch() {
|
||||
windowManager.globalSearchWindow.rootViewController = nil
|
||||
windowManager.hideGlobalSearch()
|
||||
|
||||
globalSearchScreenCoordinator = nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user