Move the global search shortcut to application commands so it's more reliable with multiple windows

This commit is contained in:
Stefan Ceriu
2026-03-30 13:01:21 +03:00
committed by Stefan Ceriu
parent aae95a9489
commit b9c5c3446a
12 changed files with 16 additions and 21 deletions

View File

@@ -64,6 +64,13 @@ struct Application: App {
}
.keyboardShortcut(",", modifiers: .command)
}
CommandGroup(after: .windowArrangement) {
Button("Global Search") {
appCoordinator.handleAppRoute(.globalSearch, windowType: nil)
}
.keyboardShortcut("k", modifiers: [.command])
}
}
// This is invoked in response of the WindowManager receiving a register

View File

@@ -53,6 +53,8 @@ enum AppRoute: Hashable {
case transferOwnership(roomID: String)
/// A thread within a room, only to be used to handle tap on notification for threaded events.
case thread(roomID: String, threadRootEventID: String, focusEventID: String?)
/// The global search screen
case globalSearch
/// Whether or not the route should be handled by the authentication flow.
var isAuthenticationRoute: Bool {

View File

@@ -170,6 +170,8 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
} else {
stateMachine.processEvent(.presentTransferOwnershipScreen(roomID: roomID))
}
case .globalSearch:
presentGlobalSearch()
case .accountProvisioningLink, .settings, .chatBackupSettings, .call, .genericCallLink:
break // These routes cannot be handled.
}
@@ -422,8 +424,6 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.processEvent(.startEncryptionResetFlow)
case .presentStartChatScreen:
stateMachine.processEvent(.startStartChatFlow)
case .presentGlobalSearch:
presentGlobalSearch()
case .logout:
actionsSubject.send(.logout)
case .presentDeclineAndBlock(let userID, let roomID):

View File

@@ -83,7 +83,8 @@ class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol {
case .roomList, .room, .roomAlias, .childRoom, .childRoomAlias,
.roomDetails, .roomMemberDetails, .userProfile, .thread,
.event, .eventOnRoomAlias, .childEvent, .childEventOnRoomAlias,
.call, .genericCallLink, .settings, .share, .transferOwnership:
.call, .genericCallLink, .settings, .share, .transferOwnership,
.globalSearch:
// These routes aren't in this flow so clear the entire stack.
clearRoute(animated: animated)
case .chatBackupSettings:

View File

@@ -199,7 +199,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
case .roomAlias, .childRoomAlias, .eventOnRoomAlias, .childEventOnRoomAlias:
break // These are converted to a room ID route one level above.
case .accountProvisioningLink, .roomList, .userProfile, .call, .genericCallLink, .settings, .chatBackupSettings:
case .accountProvisioningLink, .roomList, .userProfile, .call, .genericCallLink, .settings, .chatBackupSettings, .globalSearch:
break // These routes can't be handled.
case .transferOwnership(let roomID):
guard self.roomID == roomID else { fatalError("Navigation route doesn't belong to this room flow.") }

View File

@@ -120,7 +120,7 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
break // These are converted to a room ID route one level above.
case .accountProvisioningLink, .roomList, .room, .roomDetails, .event,
.userProfile, .call, .genericCallLink, .settings, .chatBackupSettings,
.share, .transferOwnership, .thread:
.share, .transferOwnership, .thread, .globalSearch:
break
}
}

View File

@@ -137,7 +137,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
case .roomList, .room, .roomAlias, .childRoom, .childRoomAlias,
.roomDetails, .roomMemberDetails, .userProfile,
.event, .eventOnRoomAlias, .childEvent, .childEventOnRoomAlias,
.share, .transferOwnership, .thread:
.share, .transferOwnership, .thread, .globalSearch:
clearPresentedSheets(animated: animated) // Make sure the presented route is visible.
chatsTabFlowCoordinator.handleAppRoute(appRoute, animated: animated)
if navigationTabCoordinator.selectedTab != .chats {

View File

@@ -34,7 +34,6 @@ enum HomeScreenCoordinatorAction {
case presentRecoveryKeyScreen
case presentEncryptionResetScreen
case presentStartChatScreen
case presentGlobalSearch
case logout
}
@@ -90,8 +89,6 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.presentEncryptionResetScreen)
case .presentStartChatScreen:
actionsSubject.send(.presentStartChatScreen)
case .presentGlobalSearch:
actionsSubject.send(.presentGlobalSearch)
case .logout:
actionsSubject.send(.logout)
case .transferOwnership(let roomIdentifier):

View File

@@ -25,7 +25,6 @@ enum HomeScreenViewModelAction {
case presentSettingsScreen
case presentFeedbackScreen
case presentStartChatScreen
case presentGlobalSearch
case logout
}
@@ -44,7 +43,6 @@ enum HomeScreenViewAction {
case skipRecoveryKeyConfirmation
case dismissNewSoundBanner
case updateVisibleItemRange(Range<Int>)
case globalSearch
case spaceFilters
case markRoomAsUnread(roomIdentifier: String)
case markRoomAsRead(roomIdentifier: String)

View File

@@ -199,8 +199,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
roomSummaryProvider?.updateVisibleRange(range)
case .startChat:
actionsSubject.send(.presentStartChatScreen)
case .globalSearch:
actionsSubject.send(.presentGlobalSearch)
case .spaceFilters:
if spaceFilterSubject.value != nil {
spaceFilterSubject.send(nil)

View File

@@ -99,12 +99,6 @@ struct HomeScreenContent: View {
scrollView.setContentOffset(oldOffset, animated: false)
}
}
.background {
Button("") {
context.send(viewAction: .globalSearch)
}
.keyboardShortcut(KeyEquivalent("k"), modifiers: [.command])
}
.overlay {
if context.viewState.shouldShowEmptyFilterState {
RoomListFiltersEmptyStateView(state: context.filtersState)

View File

@@ -488,8 +488,6 @@ extension HomeScreenViewModelAction: @retroactive Equatable {
true
case (.presentStartChatScreen, .presentStartChatScreen):
true
case (.presentGlobalSearch, .presentGlobalSearch):
true
case (.logout, .logout):
true
default: