Skip to content

Build your personal knowledge base with Trilium Notes

fixes and optimizations

zadamc949dcb449d7
diff --git a/db/migrations/0177__cleanup_keyboard_shortcuts.sql b/db/migrations/0177__cleanup_keyboard_shortcuts.sql
new file mode 100644
index 0000000000..148d4e61fd
--- /dev/null
+++ b/db/migrations/0177__cleanup_keyboard_shortcuts.sql
@@ -0,0 +1,5 @@
+DELETE FROM options WHERE name = 'keyboardShortcutsCreateNoteIntoInbox'; -- in case there is already one which shouldn't (except for in-dev documents)
+UPDATE options SET name = 'keyboardShortcutsCreateNoteIntoInbox' WHERE name = 'keyboardShortcutsCreateNoteIntoDayNote';
+
+DELETE FROM options WHERE name = 'keyboardShortcutsShowAttributes';
+DELETE FROM entity_changes WHERE entityName = 'options' AND entityId = 'keyboardShortcutsShowAttributes';
diff --git a/package-lock.json b/package-lock.json
index b874daad4d..7d20f5f017 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2097,6 +2097,15 @@
"requires": {
"ini": "^1.3.4",
"proto-list": "~1.2.1"
+ },
+ "dependencies": {
+ "ini": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
+ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
+ "dev": true,
+ "optional": true
+ }
}
},
"configstore": {
@@ -2246,6 +2255,28 @@
"cross-spawn": "^5.1.0"
}
},
+ "cross-spawn-windows-exe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/cross-spawn-windows-exe/-/cross-spawn-windows-exe-1.0.0.tgz",
+ "integrity": "sha512-WZzs4Ofgi/OBs1vkLmtEUX/6JjkTNWsXJqKDwIdW4lFsSzMcsGsf1OiELZL3waE/HzRO6V27cJpzqYYQRUGShQ==",
+ "dev": true,
+ "requires": {
+ "@malept/cross-spawn-promise": "^1.1.0",
+ "is-wsl": "^2.2.0",
+ "which": "^2.0.2"
+ },
+ "dependencies": {
+ "which": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "dev": true,
+ "requires": {
+ "isexe": "^2.0.0"
+ }
+ }
+ }
+ },
"crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@@ -3001,6 +3032,12 @@
"requires": {
"pump": "^3.0.0"
}
+ },
+ "rcedit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/rcedit/-/rcedit-2.3.0.tgz",
+ "integrity": "sha512-h1gNEl9Oai1oijwyJ1WYqYSXTStHnOcv1KYljg/8WM4NAg3H1KBK3azIaKkQ1WQl+d7PoJpcBMscPfLXVKgCLQ==",
+ "dev": true
}
}
},
@@ -4032,6 +4069,14 @@
"dev": true,
"requires": {
"ini": "^1.3.5"
+ },
+ "dependencies": {
+ "ini": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
+ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
+ "dev": true
+ }
}
},
"global-tunnel-ng": {
@@ -4325,9 +4370,9 @@
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
- "version": "1.3.8",
- "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
- "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-2.0.0.tgz",
+ "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA=="
},
"interpret": {
"version": "2.2.0",
@@ -6072,13 +6117,23 @@
"ini": "~1.3.0",
"minimist": "^1.2.0",
"strip-json-comments": "~2.0.1"
+ },
+ "dependencies": {
+ "ini": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
+ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
+ }
}
},
"rcedit": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/rcedit/-/rcedit-2.3.0.tgz",
- "integrity": "sha512-h1gNEl9Oai1oijwyJ1WYqYSXTStHnOcv1KYljg/8WM4NAg3H1KBK3azIaKkQ1WQl+d7PoJpcBMscPfLXVKgCLQ==",
- "dev": true
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/rcedit/-/rcedit-3.0.0.tgz",
+ "integrity": "sha512-Zg2Ihvtfzrx8XFICzQ/4aGnhw1k4Jaba8cLvVabgpxKozO0hIIS2vqTfhRkelmOmO0XW+GvmHYO2X+TRnYNlow==",
+ "dev": true,
+ "requires": {
+ "cross-spawn-windows-exe": "^1.0.0"
+ }
},
"read-config-file": {
"version": "6.0.0",
diff --git a/package.json b/package.json
index 5e693456c1..82959c0d75 100644
--- a/package.json
+++ b/package.json
@@ -47,7 +47,7 @@
"http-proxy-agent": "4.0.1",
"https-proxy-agent": "5.0.0",
"image-type": "4.1.0",
- "ini": "1.3.8",
+ "ini": "2.0.0",
"is-svg": "4.2.1",
"jimp": "0.16.1",
"jsdom": "^16.4.0",
@@ -85,7 +85,7 @@
"jasmine": "3.6.3",
"jsdoc": "3.6.6",
"lorem-ipsum": "2.0.3",
- "rcedit": "2.3.0",
+ "rcedit": "3.0.0",
"webpack": "5.10.1",
"webpack-cli": "4.2.0"
},
diff --git a/src/entities/note.js b/src/entities/note.js
index 6e42ecec18..40dec01378 100644
--- a/src/entities/note.js
+++ b/src/entities/note.js
@@ -159,7 +159,13 @@ class Note extends Entity {
const hash = utils.hash(this.noteId + "|" + content.toString());
- entityChangesService.addEntityChange('note_contents', this.noteId, hash);
+ entityChangesService.addEntityChange({
+ entityName: 'note_contents',
+ entityId: this.noteId,
+ hash: hash,
+ isErased: false,
+ utcDateChanged: this.getUtcDateChanged()
+ }, null);
}
setJsonContent(content) {
diff --git a/src/entities/note_revision.js b/src/entities/note_revision.js
index f322ed1409..1d0fdae2af 100644
--- a/src/entities/note_revision.js
+++ b/src/entities/note_revision.js
@@ -122,7 +122,13 @@ class NoteRevision extends Entity {
const hash = utils.hash(this.noteRevisionId + "|" + content);
- entityChangesService.addEntityChange('note_revision_contents', this.noteRevisionId, hash);
+ entityChangesService.addEntityChange({
+ entityName: 'note_revision_contents',
+ entityId: this.noteRevisionId,
+ hash: hash,
+ isErased: false,
+ utcDateChanged: this.getUtcDateChanged()
+ }, null);
}
beforeSaving() {
diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js
index 6995488ed5..398a066311 100644
--- a/src/public/app/entities/note_short.js
+++ b/src/public/app/entities/note_short.js
@@ -76,7 +76,7 @@ class NoteShort {
}
addChild(childNoteId, branchId, sort = true) {
- if (!this.children.includes(childNoteId)) {
+ if (!(childNoteId in this.childToBranch)) {
this.children.push(childNoteId);
}
diff --git a/src/routes/index.js b/src/routes/index.js
index 7c16b6bfb6..ec0485f6bc 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -32,8 +32,7 @@ function index(req, res) {
}
function getAppCssNoteIds() {
- return (attributeService.getNotesWithLabels(['appCss', 'appTheme']))
- .map(note => note.noteId);
+ return attributeService.getNoteIdsWithLabels(['appCss', 'appTheme']);
}
module.exports = {
diff --git a/src/services/app_info.js b/src/services/app_info.js
index ca910b47bb..0d43989475 100644
--- a/src/services/app_info.js
+++ b/src/services/app_info.js
@@ -4,8 +4,8 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
-const APP_DB_VERSION = 176;
-const SYNC_VERSION = 17;
+const APP_DB_VERSION = 177;
+const SYNC_VERSION = 18;
const CLIPPER_PROTOCOL_VERSION = "1.0";
module.exports = {
diff --git a/src/services/attributes.js b/src/services/attributes.js
index 6d526eb8cc..63d81b6532 100644
--- a/src/services/attributes.js
+++ b/src/services/attributes.js
@@ -2,6 +2,7 @@
const repository = require('./repository');
const sql = require('./sql');
+const noteCache = require('./note_cache/note_cache');
const Attribute = require('../entities/attribute');
const ATTRIBUTE_TYPES = [ 'label', 'relation' ];
@@ -64,11 +65,18 @@ function getNotesWithLabel(name, value) {
WHERE notes.isDeleted = 0 AND attributes.isDeleted = 0 AND attributes.name = ? ${valueCondition} ORDER BY position`, params);
}
-function getNotesWithLabels(names) {
- const questionMarks = names.map(() => "?").join(", ");
+function getNoteIdsWithLabels(names) {
+ const noteIds = new Set();
- return repository.getEntities(`SELECT notes.* FROM notes JOIN attributes USING(noteId)
- WHERE notes.isDeleted = 0 AND attributes.isDeleted = 0 AND attributes.name IN (${questionMarks}) ORDER BY position`, names);
+ for (const name of names) {
+ for (const attr of noteCache.findAttributes('label', name)) {
+ noteIds.add(attr.noteId);
+ }
+ }
+
+ console.log(noteIds);
+
+ return Array.from(noteIds);
}
function getNoteWithLabel(name, value) {
@@ -168,7 +176,7 @@ function sanitizeAttributeName(origName) {
module.exports = {
getNotesWithLabel,
- getNotesWithLabels,
+ getNoteIdsWithLabels,
getNoteWithLabel,
createLabel,
createRelation,
diff --git a/src/services/note_cache/entities/attribute.js b/src/services/note_cache/entities/attribute.js
index 5da56160f1..b4e524eab3 100644
--- a/src/services/note_cache/entities/attribute.js
+++ b/src/services/note_cache/entities/attribute.js
@@ -35,7 +35,7 @@ class Attribute {
this.noteCache.notes[this.noteId].ownedAttributes.push(this);
- const key = `${this.type}-${this.name}`;
+ const key = `${this.type}-${this.name.toLowerCase()}`;
this.noteCache.attributeIndex[key] = this.noteCache.attributeIndex[key] || [];
this.noteCache.attributeIndex[key].push(this);
diff --git a/src/services/note_cache/note_cache_loader.js b/src/services/note_cache/note_cache_loader.js
index 4fbe379c61..336243e15b 100644
--- a/src/services/note_cache/note_cache_loader.js
+++ b/src/services/note_cache/note_cache_loader.js
@@ -119,7 +119,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
delete noteCache.attributes[attributeId];
if (attr) {
- delete noteCache.attributeIndex[`${attr.type}-${attr.name}`];
+ delete noteCache.attributeIndex[`${attr.type}-${attr.name.toLowerCase()}`];
}
}
else if (attributeId in noteCache.attributes) {