From c2b64bad804e0c70b76b7551af9786b8c161b7b7 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 19 Oct 2020 22:10:25 +0200 Subject: [PATCH] hoisting bugfixes --- src/public/app/services/tab_context.js | 10 ++++++++++ src/public/app/services/tree.js | 4 +--- src/public/app/widgets/similar_notes.js | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/tab_context.js index 196a52cfe..937b0a075 100644 --- a/src/public/app/services/tab_context.js +++ b/src/public/app/services/tab_context.js @@ -47,6 +47,9 @@ class TabContext extends Component { if (await hoistedNoteService.checkNoteAccess(resolvedNotePath) === false) { return; // note is outside of hoisted subtree and user chose not to unhoist } + + // if user choise to unhoist, cache was reloaded, but might not contain this note (since it's on unexpanded path) + await treeCache.getNote(noteId); } await this.triggerEvent('beforeNoteSwitch', {tabContext: this}); @@ -78,10 +81,17 @@ class TabContext extends Component { notePath: this.notePath }); } + + // close dangling autocompletes after closing the tab + $(".aa-input").autocomplete("close"); } /** @property {NoteShort} */ get note() { + if (this.noteId && !(this.noteId in treeCache.notes)) { + logError(`Cannot find tabContext's note id='${this.noteId}'`); + } + return treeCache.notes[this.noteId]; } diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js index 8e285c5e6..d3718249f 100644 --- a/src/public/app/services/tree.js +++ b/src/public/app/services/tree.js @@ -62,7 +62,7 @@ async function resolveNotePathToSegments(notePath, logErrors = true) { if (!parents.length) { if (logErrors) { - ws.logError(`No parents found for ${childNoteId} (${child.title})`); + ws.logError(`No parents found for ${childNoteId} (${child.title}) for path ${notePath}`); } return; @@ -83,8 +83,6 @@ async function resolveNotePathToSegments(notePath, logErrors = true) { for (const noteId of pathToRoot) { effectivePath.push(noteId); } - - effectivePath.push('root'); } break; diff --git a/src/public/app/widgets/similar_notes.js b/src/public/app/widgets/similar_notes.js index 019c21aa1..4f281162f 100644 --- a/src/public/app/widgets/similar_notes.js +++ b/src/public/app/widgets/similar_notes.js @@ -122,6 +122,11 @@ export default class SimilarNotesWidget extends TabAwareWidget { const similarNotes = await server.get('similar-notes/' + this.noteId); + if (!similarNotes) { + this.toggleInt(false); + return; + } + this.toggleInt(similarNotes.length > 0); if (similarNotes.length === 0) {