diff --git a/package.json b/package.json index 852553822..1cc9bd480 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.47.1-beta", + "version": "0.47.2", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 702035bfa..c9e7de7d6 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -813,6 +813,7 @@ export default class NoteTreeWidget extends TabAwareWidget { const activeContext = appContext.tabManager.getActiveTabContext(); if (activeContext && activeContext.notePath) { + this.tree.$container.focus(); this.tree.setFocus(true); const node = await this.expandToNote(activeContext.notePath); diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js index daa8c3066..6df8afcc9 100644 --- a/src/services/backend_script_api.js +++ b/src/services/backend_script_api.js @@ -122,11 +122,12 @@ function BackendScriptApi(currentNote, apiParams) { * "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search * * @method - * @param {string} searchString + * @param {string} query + * @param {Object} [searchParams] * @returns {Note|null} */ - this.searchForNote = searchString => { - const notes = searchService.searchNoteEntities(searchString); + this.searchForNote = (query, searchParams = {}) => { + const notes = this.searchForNotes(query, searchParams); return notes.length > 0 ? notes[0] : null; }; diff --git a/src/services/build.js b/src/services/build.js index ded67e430..f304c7fce 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2021-04-19T22:43:03+02:00", buildRevision: "6136243d6117910b80feafad4fc7121ecc42d794" }; +module.exports = { buildDate:"2021-04-26T22:32:54+02:00", buildRevision: "6f1b0b92fe8dcea736c15217c69512c7fee769cb" }; diff --git a/src/services/entity_changes.js b/src/services/entity_changes.js index 72a389dfa..92c2e441c 100644 --- a/src/services/entity_changes.js +++ b/src/services/entity_changes.js @@ -80,31 +80,37 @@ function cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey) { function fillEntityChanges(entityName, entityPrimaryKey, condition = '') { try { cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey); + const repository = require("./repository.js"); - const entityIds = sql.getColumn(`SELECT ${entityPrimaryKey} FROM ${entityName}` - + (condition ? ` WHERE ${condition}` : '')); + sql.transactional(() => { + const entityIds = sql.getColumn(`SELECT ${entityPrimaryKey} FROM ${entityName}` + + (condition ? ` WHERE ${condition}` : '')); - let createdCount = 0; + let createdCount = 0; - for (const entityId of entityIds) { - const existingRows = sql.getValue("SELECT COUNT(1) FROM entity_changes WHERE entityName = ? AND entityId = ?", [entityName, entityId]); + for (const entityId of entityIds) { + const existingRows = sql.getValue("SELECT COUNT(1) FROM entity_changes WHERE entityName = ? AND entityId = ?", [entityName, entityId]); - // we don't want to replace existing entities (which would effectively cause full resync) - if (existingRows === 0) { - createdCount++; + // we don't want to replace existing entities (which would effectively cause full resync) + if (existingRows === 0) { + createdCount++; - sql.insert("entity_changes", { - entityName: entityName, - entityId: entityId, - sourceId: "SYNC_FILL", - isSynced: 1 - }); + const entity = repository.getEntity(`SELECT * FROM ${entityName} WHERE ${entityPrimaryKey} = ?`, [entityId]); + + addEntityChange({ + entityName, + entityId, + hash: entity.generateHash(), + isErased: false, + utcDateChanged: entity.getUtcDateChanged() + }, null); + } } - } - if (createdCount > 0) { - log.info(`Created ${createdCount} missing entity changes for ${entityName}.`); - } + if (createdCount > 0) { + log.info(`Created ${createdCount} missing entity changes for ${entityName}.`); + } + }); } catch (e) { // this is to fix migration from 0.30 to 0.32, can be removed later