reduce flicker of "create new day note"

This commit is contained in:
zadam
2019-11-24 21:40:50 +01:00
parent 3a54d00e2b
commit 6bbd4c59bc
8 changed files with 29 additions and 48 deletions

View File

@@ -1,35 +1,11 @@
import server from "./server.js";
import utils from "./utils.js";
class KeyboardAction {
constructor(params) {
/** @property {string} */
this.actionName = params.actionName;
/** @property {string[]} */
this.defaultShortcuts = params.defaultShortcuts;
/** @property {string[]} */
this.effectiveShortcuts = params.effectiveShortcuts;
/** @property {string} */
this.description = params.description;
}
addShortcut(shortcut) {
this.effectiveShortcuts.push(shortcut);
}
/**
* @param {string|string[]} shortcuts
*/
replaceShortcuts(shortcuts) {
this.effectiveShortcuts = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
}
}
const keyboardActionRepo = {};
const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
for (const action of actions) {
keyboardActionRepo[action.actionName] = new KeyboardAction(action);
keyboardActionRepo[action.actionName] = action;
}
});
@@ -54,7 +30,7 @@ function setGlobalActionHandler(actionName, handler) {
action.handler = handler;
for (const shortcut of action.effectiveShortcuts) {
if (shortcut) {
if (shortcut && !shortcut.startsWith("global:")) { // global shortcuts should be handled in the electron code
utils.bindGlobalShortcut(shortcut, handler);
}
}
@@ -80,7 +56,7 @@ function setElementActionHandler($el, actionName, handler) {
}
async function triggerAction(actionName) {
const action = getAction(actionName);
const action = await getAction(actionName);
if (!action.handler) {
throw new Error(`Action ${actionName} has no handler`);