Skip to content

Commit

Permalink
refactor: update shortcuts modal references
Browse files Browse the repository at this point in the history
  • Loading branch information
samh-nl committed Oct 8, 2023
1 parent b23c482 commit 535a29d
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion desktop/ELECTRON_EVENTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ELECTRON_EVENTS = {
REQUEST_FOCUS_APP: 'requestFocusApp',
REQUEST_UPDATE_BADGE_COUNT: 'requestUpdateBadgeCount',
REQUEST_VISIBILITY: 'requestVisibility',
SHOW_KEYBOARD_SHORTCUTS_MODAL: 'show-keyboard-shortcuts-modal',
KEYBOARD_SHORTCUTS_PAGE: 'keyboard-shortcuts-page',
START_UPDATE: 'start-update',
UPDATE_DOWNLOADED: 'update-downloaded',
};
Expand Down
2 changes: 1 addition & 1 deletion desktop/contextBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const WHITELIST_CHANNELS_RENDERER_TO_MAIN = [
ELECTRON_EVENTS.LOCALE_UPDATED,
];

const WHITELIST_CHANNELS_MAIN_TO_RENDERER = [ELECTRON_EVENTS.SHOW_KEYBOARD_SHORTCUTS_MODAL, ELECTRON_EVENTS.UPDATE_DOWNLOADED, ELECTRON_EVENTS.FOCUS, ELECTRON_EVENTS.BLUR];
const WHITELIST_CHANNELS_MAIN_TO_RENDERER = [ELECTRON_EVENTS.KEYBOARD_SHORTCUTS_PAGE, ELECTRON_EVENTS.UPDATE_DOWNLOADED, ELECTRON_EVENTS.FOCUS, ELECTRON_EVENTS.BLUR];

const getErrorMessage = (channel) => `Electron context bridge cannot be used with channel '${channel}'`;

Expand Down
6 changes: 3 additions & 3 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ const manuallyCheckForUpdates = (menuItem, browserWindow) => {
* Trigger event to show keyboard shortcuts
* @param {BrowserWindow} browserWindow
*/
const showKeyboardShortcutsModal = (browserWindow) => {
const showKeyboardShortcutsPage = (browserWindow) => {
if (!browserWindow.isVisible()) {
return;
}
browserWindow.webContents.send(ELECTRON_EVENTS.SHOW_KEYBOARD_SHORTCUTS_MODAL);
browserWindow.webContents.send(ELECTRON_EVENTS.KEYBOARD_SHORTCUTS_PAGE);
};

// Actual auto-update listeners
Expand Down Expand Up @@ -332,7 +332,7 @@ const mainWindow = () => {
label: Localize.translate(preferredLocale, `desktopApplicationMenu.viewShortcuts`),
accelerator: 'CmdOrCtrl+I',
click: () => {
showKeyboardShortcutsModal(browserWindow);
showKeyboardShortcutsPage(browserWindow);
},
},
{type: 'separator'},
Expand Down
2 changes: 1 addition & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ const CONST = {
},
type: KEYBOARD_SHORTCUT_NAVIGATION_TYPE,
},
SHORTCUT_MODAL: {
SHORTCUTS: {
descriptionKey: 'openShortcutDialog',
shortcutKey: 'J',
modifiers: ['CTRL'],
Expand Down
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ const ONYXKEYS = {
/** Is report data loading? */
IS_LOADING_APP: 'isLoadingApp',

/** Is Keyboard shortcuts modal open? */
IS_SHORTCUTS_MODAL_OPEN: 'isShortcutsModalOpen',

/** Is the test tools modal open? */
IS_TEST_TOOLS_MODAL_OPEN: 'isTestToolsModalOpen',

Expand Down Expand Up @@ -351,7 +348,6 @@ type OnyxValues = {
[ONYXKEYS.REIMBURSEMENT_ACCOUNT_WORKSPACE_ID]: string;
[ONYXKEYS.IS_LOADING_PAYMENT_METHODS]: boolean;
[ONYXKEYS.IS_LOADING_REPORT_DATA]: boolean;
[ONYXKEYS.IS_SHORTCUTS_MODAL_OPEN]: boolean;
[ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN]: boolean;
[ONYXKEYS.WALLET_TRANSFER]: OnyxTypes.WalletTransfer;
[ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID]: string;
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ export default {
statementPage: {
generatingPDF: "We're generating your PDF right now. Please come back later!",
},
keyboardShortcutModal: {
keyboardShortcutsPage: {
title: 'Keyboard shortcuts',
subtitle: 'Save time with these handy keyboard shortcuts:',
shortcuts: {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ export default {
statementPage: {
generatingPDF: 'Estamos generando tu PDF ahora mismo. ¡Por favor, vuelve más tarde!',
},
keyboardShortcutModal: {
keyboardShortcutsPage: {
title: 'Atajos de teclado',
subtitle: 'Ahorra tiempo con estos atajos de teclado:',
shortcuts: {
Expand Down
7 changes: 5 additions & 2 deletions src/setup/platformSetup/index.desktop.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {AppRegistry} from 'react-native';
import Config from '../../CONFIG';
import LocalNotification from '../../libs/Notification/LocalNotification';
import * as KeyboardShortcuts from '../../libs/actions/KeyboardShortcuts';
import DateUtils from '../../libs/DateUtils';
import ELECTRON_EVENTS from '../../../desktop/ELECTRON_EVENTS';
import ROUTES from '../../ROUTES';
import Navigation from '../../libs/Navigation/Navigation';

export default function () {
AppRegistry.runApplication(Config.APP_NAME, {
Expand All @@ -16,7 +17,9 @@ export default function () {
});

// Trigger action to show keyboard shortcuts
window.electron.on(ELECTRON_EVENTS.SHOW_KEYBOARD_SHORTCUTS_MODAL, KeyboardShortcuts.showKeyboardShortcutModal);
window.electron.on(ELECTRON_EVENTS.KEYBOARD_SHORTCUTS_PAGE, () => {
Navigation.navigate(ROUTES.KEYBOARD_SHORTCUTS);
});

// Start current date updater
DateUtils.startCurrentDateUpdater();
Expand Down

0 comments on commit 535a29d

Please sign in to comment.