Skip to content

Commit

Permalink
fix: restore cmd+J shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
barttom committed Oct 25, 2023
1 parent 8a2c5e4 commit f0981d1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function AuthScreens({isUsingMemoryOnlyKeys, lastUpdateIDAppliedToClient, sessio
}

useEffect(() => {
const shortcutsOverviewShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SHORTCUTS;
const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH;
const chatShortcutConfig = CONST.KEYBOARD_SHORTCUTS.NEW_CHAT;
const shouldGetAllData = isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession();
Expand Down Expand Up @@ -206,17 +207,33 @@ function AuthScreens({isUsingMemoryOnlyKeys, lastUpdateIDAppliedToClient, sessio

Timing.end(CONST.TIMING.HOMEPAGE_INITIAL_RENDER);

// Listen to keyboard shortcuts for opening certain pages
const unsubscribeShortcutsOverviewShortcut = KeyboardShortcut.subscribe(
shortcutsOverviewShortcutConfig.shortcutKey,
() => {
Modal.close(() => {
if (Navigation.isActiveRoute(ROUTES.KEYBOARD_SHORTCUTS)) {
return;
}
return Navigation.navigate(ROUTES.KEYBOARD_SHORTCUTS);
});
},
shortcutsOverviewShortcutConfig.descriptionKey,
shortcutsOverviewShortcutConfig.modifiers,
true,
);

// Listen for the key K being pressed so that focus can be given to
// the chat switcher, or new group chat
// based on the key modifiers pressed and the operating system
const unsubscribeSearchShortcut = KeyboardShortcut.subscribe(
searchShortcutConfig.shortcutKey,
() => {
Modal.close(() => {
if (Navigation.isActiveRoute(ROUTES.KEYBOARD_SHORTCUTS)) {
if (Navigation.isActiveRoute(ROUTES.SEARCH)) {
return;
}
return Navigation.navigate(ROUTES.KEYBOARD_SHORTCUTS);
return Navigation.navigate(ROUTES.SEARCH);
});
},
shortcutsOverviewShortcutConfig.descriptionKey,
Expand All @@ -243,6 +260,7 @@ function AuthScreens({isUsingMemoryOnlyKeys, lastUpdateIDAppliedToClient, sessio
);

return () => {
unsubscribeShortcutsOverviewShortcut();
unsubscribeSearchShortcut();
unsubscribeChatShortcut();
Session.cleanupSession();
Expand Down

0 comments on commit f0981d1

Please sign in to comment.