fixes and optimizations

This commit is contained in:
zadam 2020-12-14 22:12:26 +01:00
parent 8b99f065d5
commit c949dcb449
11 changed files with 102 additions and 23 deletions

View file

@ -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';

69
package-lock.json generated
View file

@ -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",

View file

@ -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"
},

View file

@ -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) {

View file

@ -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() {

View file

@ -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);
}

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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,

View file

@ -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);

View file

@ -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) {