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 diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index c326ac2d3..f8fe862ac 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -196,8 +196,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/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(); 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; } 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') { 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) {