diff --git a/src/public/app/services/main_tree_executors.js b/src/public/app/services/main_tree_executors.js index c4bab5b28..a365393f3 100644 --- a/src/public/app/services/main_tree_executors.js +++ b/src/public/app/services/main_tree_executors.js @@ -38,12 +38,6 @@ export default class MainTreeExecutors extends Component { isProtected: activeNote.isProtected, saveSelection: false }); - - await ws.waitForMaxKnownSyncId(); - - appContext.tabManager.getActiveTabContext().setNote(note.noteId); - - appContext.triggerCommand('focusAndSelectTitle'); } async createNoteAfterCommand() { @@ -55,17 +49,11 @@ export default class MainTreeExecutors extends Component { return; } - const {note} = await noteCreateService.createNote(parentNoteId, { + await noteCreateService.createNote(parentNoteId, { target: 'after', targetBranchId: node.data.branchId, isProtected: isProtected, saveSelection: false }); - - await ws.waitForMaxKnownSyncId(); - - appContext.tabManager.getActiveTabContext().setNote(note.noteId); - - appContext.triggerCommand('focusAndSelectTitle'); } } \ No newline at end of file diff --git a/src/public/app/services/note_create.js b/src/public/app/services/note_create.js index 24501f10c..353bc7a36 100644 --- a/src/public/app/services/note_create.js +++ b/src/public/app/services/note_create.js @@ -48,8 +48,12 @@ async function createNote(parentNoteId, options = {}) { } if (options.activate) { + await ws.waitForMaxKnownSyncId(); + const activeTabContext = appContext.tabManager.getActiveTabContext(); - activeTabContext.setNote(note.noteId); + await activeTabContext.setNote(note.noteId); + + appContext.triggerCommand('focusAndSelectTitle'); } return {note, branch}; diff --git a/src/public/app/widgets/run_script_buttons.js b/src/public/app/widgets/run_script_buttons.js index a94a1e54f..a93bd7707 100644 --- a/src/public/app/widgets/run_script_buttons.js +++ b/src/public/app/widgets/run_script_buttons.js @@ -23,4 +23,10 @@ export default class RunScriptButtonsWidget extends TabAwareWidget { this.$renderButton.toggle(note.type === 'render'); this.$executeScriptButton.toggle(note.mime.startsWith('application/javascript')); } + + async entitiesReloadedEvent({loadResults}) { + if (loadResults.isNoteReloaded(this.noteId)) { + this.refresh(); + } + } } \ No newline at end of file