server: Fix crash when starting server in Docker due to translations

This commit is contained in:
Elian Doran 2024-10-12 10:29:50 +03:00
parent 5c44ac5ad8
commit e45c5f429d
No known key found for this signature in database
2 changed files with 597 additions and 590 deletions

View File

@ -18,6 +18,7 @@ const isElectron = utils.isElectron();
* e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.
*/
function getDefaultKeyboardActions() {
if (!t("keyboard_actions.note-navigation")) {
throw new Error("Keyboard actions loaded before translations.");
}
@ -602,6 +603,9 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
}
];
/*
* Apply macOS-specific tweaks.
*/
const platformModifier = isMac ? 'Meta' : 'Ctrl';
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
@ -610,8 +614,11 @@ for (const action of DEFAULT_KEYBOARD_ACTIONS) {
}
}
return DEFAULT_KEYBOARD_ACTIONS;
}
function getKeyboardActions() {
const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(getDefaultKeyboardActions()));
for (const action of actions) {
action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : [];
@ -642,6 +649,6 @@ function getKeyboardActions() {
}
export default {
DEFAULT_KEYBOARD_ACTIONS,
getDefaultKeyboardActions,
getKeyboardActions
};

View File

@ -126,7 +126,7 @@ function initStartupOptions() {
}
function getKeyboardDefaultOptions() {
return (keyboardActions.DEFAULT_KEYBOARD_ACTIONS
return (keyboardActions.getDefaultKeyboardActions()
.filter(ka => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[])
.map(ka => ({
name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`,