From a8a8741c06a9942038fe1f40b75b708b28410732 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Fri, 12 Mar 2021 19:40:28 +1300 Subject: [PATCH] Make FocusRoomSearch a NavigationAction --- src/KeyBindingsDefaults.ts | 18 +++++++++--------- src/KeyBindingsManager.ts | 4 ++-- src/components/structures/LoggedInView.tsx | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/KeyBindingsDefaults.ts b/src/KeyBindingsDefaults.ts index fd00a2ff53..0e9d14ea8f 100644 --- a/src/KeyBindingsDefaults.ts +++ b/src/KeyBindingsDefaults.ts @@ -251,14 +251,7 @@ const roomListBindings = (): KeyBinding[] => { } const roomBindings = (): KeyBinding[] => { - const bindings = [ - { - action: RoomAction.FocusRoomSearch, - keyCombo: { - key: Key.K, - ctrlOrCmd: true, - }, - }, + const bindings: KeyBinding[] = [ { action: RoomAction.ScrollUp, keyCombo: { @@ -323,6 +316,13 @@ const roomBindings = (): KeyBinding[] => { const navigationBindings = (): KeyBinding[] => { return [ + { + action: NavigationAction.FocusRoomSearch, + keyCombo: { + key: Key.K, + ctrlOrCmd: true, + }, + }, { action: NavigationAction.ToggleRoomSidePanel, keyCombo: { @@ -395,7 +395,7 @@ const navigationBindings = (): KeyBinding[] => { shiftKey: true, }, }, - ] + ]; } export const defaultBindingsProvider: IKeyBindingsProvider = { diff --git a/src/KeyBindingsManager.ts b/src/KeyBindingsManager.ts index 7e996b2730..73940e0371 100644 --- a/src/KeyBindingsManager.ts +++ b/src/KeyBindingsManager.ts @@ -78,8 +78,6 @@ export enum RoomListAction { /** Actions for the current room view */ export enum RoomAction { - /** Jump to room search (search for a room)*/ - FocusRoomSearch = 'FocusRoomSearch', // TODO: move to NavigationAction? /** Scroll up in the timeline */ ScrollUp = 'ScrollUp', /** Scroll down in the timeline */ @@ -100,6 +98,8 @@ export enum RoomAction { /** Actions for navigating do various menus / dialogs / screens */ export enum NavigationAction { + /** Jump to room search (search for a room)*/ + FocusRoomSearch = 'FocusRoomSearch', /** Toggle the room side panel */ ToggleRoomSidePanel = 'ToggleRoomSidePanel', /** Toggle the user menu */ diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index dcc140148d..9360ab4e9e 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -449,12 +449,6 @@ class LoggedInView extends React.Component { const roomAction = getKeyBindingsManager().getRoomAction(ev); switch (roomAction) { - case RoomAction.FocusRoomSearch: - dis.dispatch({ - action: 'focus_room_filter', - }); - handled = true; - break; case RoomAction.ScrollUp: case RoomAction.RoomScrollDown: case RoomAction.JumpToFirstMessage: @@ -477,6 +471,12 @@ class LoggedInView extends React.Component { const navAction = getKeyBindingsManager().getNavigationAction(ev); switch (navAction) { + case NavigationAction.FocusRoomSearch: + dis.dispatch({ + action: 'focus_room_filter', + }); + handled = true; + break; case NavigationAction.ToggleUserMenu: dis.fire(Action.ToggleUserMenu); handled = true;