diff --git a/electron.js b/electron.js index ba5e3b556..04ae7a285 100644 --- a/electron.js +++ b/electron.js @@ -3,6 +3,7 @@ const electron = require('electron'); const path = require('path'); const log = require('./src/services/log'); +const cls = require('./src/services/cls'); const url = require("url"); const port = require('./src/services/port'); @@ -68,10 +69,10 @@ app.on('activate', () => { } }); -app.on('ready', () => { - mainWindow = createMainWindow(); +app.on('ready', async () => { + mainWindow = await createMainWindow(); - const result = globalShortcut.register('CommandOrControl+Alt+P', async () => { + const result = globalShortcut.register('CommandOrControl+Alt+P', cls.wrap(async () => { const dateNoteService = require('./src/services/date_notes'); const dateUtils = require('./src/services/date_utils'); @@ -81,7 +82,7 @@ app.on('ready', () => { mainWindow.focus(); mainWindow.webContents.send('create-day-sub-note', parentNote.noteId); - }); + })); if (!result) { log.error("Could not register global shortcut CTRL+ALT+P"); diff --git a/package-lock.json b/package-lock.json index 6e6ed7205..c968df3d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -937,11 +937,6 @@ "chainsaw": "~0.1.0" } }, - "bindings": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", - "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==" - }, "bl": { "version": "1.2.2", "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", @@ -6579,11 +6574,6 @@ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, - "nan": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", - "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", diff --git a/src/public/javascripts/services/bootstrap.js b/src/public/javascripts/services/bootstrap.js index 3fc7b0a68..faef8b055 100644 --- a/src/public/javascripts/services/bootstrap.js +++ b/src/public/javascripts/services/bootstrap.js @@ -90,10 +90,13 @@ if (utils.isElectron()) { await treeService.activateNote(parentNoteId); - setTimeout(() => { - const node = treeService.getCurrentNode(); + setTimeout(async () => { + const parentNode = treeService.getCurrentNode(); + + const {note} = await treeService.createNote(parentNode, parentNode.data.noteId, 'into', parentNode.data.isProtected); + + await treeService.activateNote(note.noteId); - treeService.createNote(node, node.data.noteId, 'into', node.data.isProtected); }, 500); }); } diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index c37c3b037..9d5d85925 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -522,6 +522,8 @@ async function createNote(node, parentNoteId, target, isProtected, saveSelection clearSelectedNodes(); // to unmark previously active node infoService.showMessage("Created!"); + + return {note, branch}; } /* If first element is heading, parse it out and use it as a new heading. */