diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js index 41337f4bc..be966ee45 100644 --- a/src/public/javascripts/services/frontend_script_api.js +++ b/src/public/javascripts/services/frontend_script_api.js @@ -294,7 +294,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte * @return {boolean} returns true if the original note is still loaded, false if user switched to another */ this.isNoteStillActive = () => { - return this.originEntity.noteId === tabContext.noteId; + return tabContext.note && this.originEntity.noteId === tabContext.note.noteId; }; /** diff --git a/src/public/javascripts/services/link_map.js b/src/public/javascripts/services/link_map.js index 354f8aa9c..c3e3bb0ee 100644 --- a/src/public/javascripts/services/link_map.js +++ b/src/public/javascripts/services/link_map.js @@ -55,7 +55,7 @@ export default class LinkMap { } // preload all notes - const notes = await treeCache.getNotes(Array.from(noteIds)); + const notes = await treeCache.getNotes(Array.from(noteIds), true); const graph = new Springy.Graph(); graph.addNodes(...noteIds); diff --git a/src/public/javascripts/services/protected_session.js b/src/public/javascripts/services/protected_session.js index c24adbbaa..1ca0d3730 100644 --- a/src/public/javascripts/services/protected_session.js +++ b/src/public/javascripts/services/protected_session.js @@ -27,7 +27,7 @@ function enterProtectedSession() { // using deferred instead of promise because it allows resolving from outside protectedSessionDeferred = dfd; - import("../dialogs/protected_session.js").then(protectedSessionDialog => protectedSessionDialog.show()) + import("../dialogs/protected_session.js").then(dialog => dialog.show()); } return dfd.promise(); @@ -51,7 +51,7 @@ async function setupProtectedSession(password) { await noteDetailService.reloadAllTabs(); if (protectedSessionDeferred !== null) { - protectedSessionDialog.close(); + import("../dialogs/protected_session.js").then(dialog => dialog.close()); protectedSessionDeferred.resolve(true); protectedSessionDeferred = null; diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.js index 36a72ce87..eebf5f9a0 100644 --- a/src/public/javascripts/services/tab_context.js +++ b/src/public/javascripts/services/tab_context.js @@ -135,6 +135,8 @@ class TabContext { return; } + this.$scriptArea.empty(); + if (utils.isDesktop()) { this.attributes.refreshAttributes(); } else { diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 79078152d..43079bd38 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -818,8 +818,6 @@ $(window).bind('hashchange', async function() { if (isNotePathInAddress()) { const [notePath, tabId] = getHashValueFromAddress(); - console.debug(`Switching to ${notePath} on tab ${tabId} because of hash change`); - noteDetailService.switchToTab(tabId, notePath); } }); diff --git a/src/public/javascripts/services/tree_cache.js b/src/public/javascripts/services/tree_cache.js index bc70af3b9..88ab03df0 100644 --- a/src/public/javascripts/services/tree_cache.js +++ b/src/public/javascripts/services/tree_cache.js @@ -121,12 +121,12 @@ class TreeCache { } /** @return {Promise} */ - async getNote(noteId) { + async getNote(noteId, silentNotFoundError = false) { if (noteId === 'none') { return null; } - return (await this.getNotes([noteId]))[0]; + return (await this.getNotes([noteId], silentNotFoundError))[0]; } addBranch(branch) { diff --git a/src/public/javascripts/widgets/edited_notes.js b/src/public/javascripts/widgets/edited_notes.js index 012e1717d..969da93cf 100644 --- a/src/public/javascripts/widgets/edited_notes.js +++ b/src/public/javascripts/widgets/edited_notes.js @@ -28,19 +28,20 @@ class EditedNotesWidget extends StandardWidget { const noteIds = editedNotes.flatMap(note => note.notePath); - await treeCache.getNotes(noteIds); // preload all at once + await treeCache.getNotes(noteIds, true); // preload all at once const $list = $('