Move the global search shortcut to application commands so it's more reliable with multiple windows
This commit is contained in:
committed by
Stefan Ceriu
parent
aae95a9489
commit
b9c5c3446a
@@ -64,6 +64,13 @@ struct Application: App {
|
|||||||
}
|
}
|
||||||
.keyboardShortcut(",", modifiers: .command)
|
.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
|
// This is invoked in response of the WindowManager receiving a register
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ enum AppRoute: Hashable {
|
|||||||
case transferOwnership(roomID: String)
|
case transferOwnership(roomID: String)
|
||||||
/// A thread within a room, only to be used to handle tap on notification for threaded events.
|
/// 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?)
|
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.
|
/// Whether or not the route should be handled by the authentication flow.
|
||||||
var isAuthenticationRoute: Bool {
|
var isAuthenticationRoute: Bool {
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
} else {
|
} else {
|
||||||
stateMachine.processEvent(.presentTransferOwnershipScreen(roomID: roomID))
|
stateMachine.processEvent(.presentTransferOwnershipScreen(roomID: roomID))
|
||||||
}
|
}
|
||||||
|
case .globalSearch:
|
||||||
|
presentGlobalSearch()
|
||||||
case .accountProvisioningLink, .settings, .chatBackupSettings, .call, .genericCallLink:
|
case .accountProvisioningLink, .settings, .chatBackupSettings, .call, .genericCallLink:
|
||||||
break // These routes cannot be handled.
|
break // These routes cannot be handled.
|
||||||
}
|
}
|
||||||
@@ -422,8 +424,6 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
stateMachine.processEvent(.startEncryptionResetFlow)
|
stateMachine.processEvent(.startEncryptionResetFlow)
|
||||||
case .presentStartChatScreen:
|
case .presentStartChatScreen:
|
||||||
stateMachine.processEvent(.startStartChatFlow)
|
stateMachine.processEvent(.startStartChatFlow)
|
||||||
case .presentGlobalSearch:
|
|
||||||
presentGlobalSearch()
|
|
||||||
case .logout:
|
case .logout:
|
||||||
actionsSubject.send(.logout)
|
actionsSubject.send(.logout)
|
||||||
case .presentDeclineAndBlock(let userID, let roomID):
|
case .presentDeclineAndBlock(let userID, let roomID):
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .roomList, .room, .roomAlias, .childRoom, .childRoomAlias,
|
case .roomList, .room, .roomAlias, .childRoom, .childRoomAlias,
|
||||||
.roomDetails, .roomMemberDetails, .userProfile, .thread,
|
.roomDetails, .roomMemberDetails, .userProfile, .thread,
|
||||||
.event, .eventOnRoomAlias, .childEvent, .childEventOnRoomAlias,
|
.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.
|
// These routes aren't in this flow so clear the entire stack.
|
||||||
clearRoute(animated: animated)
|
clearRoute(animated: animated)
|
||||||
case .chatBackupSettings:
|
case .chatBackupSettings:
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
case .roomAlias, .childRoomAlias, .eventOnRoomAlias, .childEventOnRoomAlias:
|
case .roomAlias, .childRoomAlias, .eventOnRoomAlias, .childEventOnRoomAlias:
|
||||||
break // These are converted to a room ID route one level above.
|
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.
|
break // These routes can't be handled.
|
||||||
case .transferOwnership(let roomID):
|
case .transferOwnership(let roomID):
|
||||||
guard self.roomID == roomID else { fatalError("Navigation route doesn't belong to this room flow.") }
|
guard self.roomID == roomID else { fatalError("Navigation route doesn't belong to this room flow.") }
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
break // These are converted to a room ID route one level above.
|
break // These are converted to a room ID route one level above.
|
||||||
case .accountProvisioningLink, .roomList, .room, .roomDetails, .event,
|
case .accountProvisioningLink, .roomList, .room, .roomDetails, .event,
|
||||||
.userProfile, .call, .genericCallLink, .settings, .chatBackupSettings,
|
.userProfile, .call, .genericCallLink, .settings, .chatBackupSettings,
|
||||||
.share, .transferOwnership, .thread:
|
.share, .transferOwnership, .thread, .globalSearch:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .roomList, .room, .roomAlias, .childRoom, .childRoomAlias,
|
case .roomList, .room, .roomAlias, .childRoom, .childRoomAlias,
|
||||||
.roomDetails, .roomMemberDetails, .userProfile,
|
.roomDetails, .roomMemberDetails, .userProfile,
|
||||||
.event, .eventOnRoomAlias, .childEvent, .childEventOnRoomAlias,
|
.event, .eventOnRoomAlias, .childEvent, .childEventOnRoomAlias,
|
||||||
.share, .transferOwnership, .thread:
|
.share, .transferOwnership, .thread, .globalSearch:
|
||||||
clearPresentedSheets(animated: animated) // Make sure the presented route is visible.
|
clearPresentedSheets(animated: animated) // Make sure the presented route is visible.
|
||||||
chatsTabFlowCoordinator.handleAppRoute(appRoute, animated: animated)
|
chatsTabFlowCoordinator.handleAppRoute(appRoute, animated: animated)
|
||||||
if navigationTabCoordinator.selectedTab != .chats {
|
if navigationTabCoordinator.selectedTab != .chats {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ enum HomeScreenCoordinatorAction {
|
|||||||
case presentRecoveryKeyScreen
|
case presentRecoveryKeyScreen
|
||||||
case presentEncryptionResetScreen
|
case presentEncryptionResetScreen
|
||||||
case presentStartChatScreen
|
case presentStartChatScreen
|
||||||
case presentGlobalSearch
|
|
||||||
case logout
|
case logout
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +89,6 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
|
|||||||
actionsSubject.send(.presentEncryptionResetScreen)
|
actionsSubject.send(.presentEncryptionResetScreen)
|
||||||
case .presentStartChatScreen:
|
case .presentStartChatScreen:
|
||||||
actionsSubject.send(.presentStartChatScreen)
|
actionsSubject.send(.presentStartChatScreen)
|
||||||
case .presentGlobalSearch:
|
|
||||||
actionsSubject.send(.presentGlobalSearch)
|
|
||||||
case .logout:
|
case .logout:
|
||||||
actionsSubject.send(.logout)
|
actionsSubject.send(.logout)
|
||||||
case .transferOwnership(let roomIdentifier):
|
case .transferOwnership(let roomIdentifier):
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ enum HomeScreenViewModelAction {
|
|||||||
case presentSettingsScreen
|
case presentSettingsScreen
|
||||||
case presentFeedbackScreen
|
case presentFeedbackScreen
|
||||||
case presentStartChatScreen
|
case presentStartChatScreen
|
||||||
case presentGlobalSearch
|
|
||||||
case logout
|
case logout
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ enum HomeScreenViewAction {
|
|||||||
case skipRecoveryKeyConfirmation
|
case skipRecoveryKeyConfirmation
|
||||||
case dismissNewSoundBanner
|
case dismissNewSoundBanner
|
||||||
case updateVisibleItemRange(Range<Int>)
|
case updateVisibleItemRange(Range<Int>)
|
||||||
case globalSearch
|
|
||||||
case spaceFilters
|
case spaceFilters
|
||||||
case markRoomAsUnread(roomIdentifier: String)
|
case markRoomAsUnread(roomIdentifier: String)
|
||||||
case markRoomAsRead(roomIdentifier: String)
|
case markRoomAsRead(roomIdentifier: String)
|
||||||
|
|||||||
@@ -199,8 +199,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
|||||||
roomSummaryProvider?.updateVisibleRange(range)
|
roomSummaryProvider?.updateVisibleRange(range)
|
||||||
case .startChat:
|
case .startChat:
|
||||||
actionsSubject.send(.presentStartChatScreen)
|
actionsSubject.send(.presentStartChatScreen)
|
||||||
case .globalSearch:
|
|
||||||
actionsSubject.send(.presentGlobalSearch)
|
|
||||||
case .spaceFilters:
|
case .spaceFilters:
|
||||||
if spaceFilterSubject.value != nil {
|
if spaceFilterSubject.value != nil {
|
||||||
spaceFilterSubject.send(nil)
|
spaceFilterSubject.send(nil)
|
||||||
|
|||||||
@@ -99,12 +99,6 @@ struct HomeScreenContent: View {
|
|||||||
scrollView.setContentOffset(oldOffset, animated: false)
|
scrollView.setContentOffset(oldOffset, animated: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.background {
|
|
||||||
Button("") {
|
|
||||||
context.send(viewAction: .globalSearch)
|
|
||||||
}
|
|
||||||
.keyboardShortcut(KeyEquivalent("k"), modifiers: [.command])
|
|
||||||
}
|
|
||||||
.overlay {
|
.overlay {
|
||||||
if context.viewState.shouldShowEmptyFilterState {
|
if context.viewState.shouldShowEmptyFilterState {
|
||||||
RoomListFiltersEmptyStateView(state: context.filtersState)
|
RoomListFiltersEmptyStateView(state: context.filtersState)
|
||||||
|
|||||||
@@ -488,8 +488,6 @@ extension HomeScreenViewModelAction: @retroactive Equatable {
|
|||||||
true
|
true
|
||||||
case (.presentStartChatScreen, .presentStartChatScreen):
|
case (.presentStartChatScreen, .presentStartChatScreen):
|
||||||
true
|
true
|
||||||
case (.presentGlobalSearch, .presentGlobalSearch):
|
|
||||||
true
|
|
||||||
case (.logout, .logout):
|
case (.logout, .logout):
|
||||||
true
|
true
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user