From 7f5af4b959af7b54849a563a41287d8ab11cff67 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Oct 2020 15:57:37 +0100 Subject: [PATCH 1/6] fix broken addTextToActiveEditor API method, closes #1332 --- package-lock.json | 2 +- src/public/app/widgets/type_widgets/editable_text.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0653afe78..272f64cbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.44.9", + "version": "0.45.0-beta", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js index 1729f3c29..12999e336 100644 --- a/src/public/app/widgets/type_widgets/editable_text.js +++ b/src/public/app/widgets/type_widgets/editable_text.js @@ -181,7 +181,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { }); } - addTextToActiveEditorEvent(text) { + addTextToActiveEditorEvent({text}) { if (!this.isActive()) { return; } From 9f424836e29cf2d5a11f0dd34fb94b736a51fda1 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Oct 2020 16:05:34 +0100 Subject: [PATCH 2/6] fix adding relation noteId as value, closes #1329 --- src/public/app/widgets/attribute_detail.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js index 4274a8014..95c9865f5 100644 --- a/src/public/app/widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_detail.js @@ -283,7 +283,9 @@ export default class AttributeDetailWidget extends TabAwareWidget { return false; } - this.attribute.value = suggestion.notePath; + const pathChunks = suggestion.notePath.split('/'); + + this.attribute.value = pathChunks[pathChunks.length - 1]; // noteId this.triggerCommand('updateAttributeList', { attributes: this.allAttributes }); this.updateRelatedNotes(); From c671b0a345813910401ba31c4e84962571544123 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Oct 2020 19:02:33 +0100 Subject: [PATCH 3/6] fix OPML import, closes #1333 --- src/services/import/opml.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/import/opml.js b/src/services/import/opml.js index 30a0b2399..df1150fd2 100644 --- a/src/services/import/opml.js +++ b/src/services/import/opml.js @@ -11,8 +11,8 @@ const htmlSanitizer = require('../html_sanitizer'); * @param {Note} parentNote * @return {Promise<*[]|*>} */ -function importOpml(taskContext, fileBuffer, parentNote) { - const xml = new Promise(function(resolve, reject) +async function importOpml(taskContext, fileBuffer, parentNote) { + const xml = await new Promise(function(resolve, reject) { parseString(fileBuffer, function (err, result) { if (err) { From 8901c3ec9154124be14cf825be8905f79f58fcc2 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Oct 2020 19:58:56 +0100 Subject: [PATCH 4/6] fix recent changes showing deleted search note, closes #1331 --- src/public/app/services/tree_cache.js | 4 ++-- src/routes/api/search.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index 6db371627..c252aebbe 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -191,8 +191,8 @@ class TreeCache { if (note.type === 'search') { const searchResultNoteIds = await server.get('search-note/' + note.noteId); - if (!searchResultNoteIds) { - throw new Error(`Search note ${note.noteId} failed.`); + if (!Array.isArray(searchResultNoteIds)) { + throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`); } // force to load all the notes at once instead of one by one diff --git a/src/routes/api/search.js b/src/routes/api/search.js index ef81122f6..201c7bbbf 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -38,7 +38,8 @@ async function searchFromNote(req) { } if (note.isDeleted) { - return [400, `Note ${req.params.noteId} is deleted.`]; + // this can be triggered from recent changes and it's harmless to return empty list rather than fail + return []; } if (note.type !== 'search') { From 0afd3c65aad95edc7800180a43d6094fbc507e4a Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Oct 2020 20:11:43 +0100 Subject: [PATCH 5/6] fix setting note title on back/forward button click, closes #1334 --- src/public/app/services/tab_manager.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index fd29172d4..b6fd5475d 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -115,13 +115,13 @@ export default class TabManager extends Component { // using pushState instead of directly modifying document.location because it does not trigger hashchange window.history.pushState(null, "", url); + } - document.title = "Trilium Notes"; + document.title = "Trilium Notes"; - if (activeTabContext.note) { - // it helps navigating in history if note title is included in the title - document.title += " - " + activeTabContext.note.title; - } + if (activeTabContext.note) { + // it helps navigating in history if note title is included in the title + document.title += " - " + activeTabContext.note.title; } this.triggerEvent('activeNoteChanged'); // trigger this even in on popstate event From 93d0324177a34cb79caf410ff7fc14a18c4f2633 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 24 Oct 2020 00:02:10 +0200 Subject: [PATCH 6/6] fix case where parents of templates are not loaded (cherry picked from commit a3f4fc77624ef1b6e92a43068c7b6aded9d90243) --- src/public/app/services/tree_cache.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index c252aebbe..f8fe862ac 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -20,6 +20,9 @@ class TreeCache { async loadInitialTree() { const resp = await server.get('tree'); + // FIXME: we need to do this to cover for ascendants of template notes which are not loaded + await this.loadParents(resp, false); + // clear the cache only directly before adding new content which is important for e.g. switching to protected session /** @type {Object.} */ @@ -40,6 +43,8 @@ class TreeCache { async loadSubTree(subTreeNoteId) { const resp = await server.get('tree?subTreeNoteId=' + subTreeNoteId); + await this.loadParents(resp, true); + this.addResp(resp); return this.notes[subTreeNoteId];