mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fixes and optimizations
This commit is contained in:
		
							
								
								
									
										5
									
								
								db/migrations/0177__cleanup_keyboard_shortcuts.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								db/migrations/0177__cleanup_keyboard_shortcuts.sql
									
									
									
									
									
										Normal 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
									
									
									
								
							
							
						
						
									
										69
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -2097,6 +2097,15 @@ | |||||||
|       "requires": { |       "requires": { | ||||||
|         "ini": "^1.3.4", |         "ini": "^1.3.4", | ||||||
|         "proto-list": "~1.2.1" |         "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": { |     "configstore": { | ||||||
| @@ -2246,6 +2255,28 @@ | |||||||
|         "cross-spawn": "^5.1.0" |         "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": { |     "crypto-random-string": { | ||||||
|       "version": "2.0.0", |       "version": "2.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", |       "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", | ||||||
| @@ -3001,6 +3032,12 @@ | |||||||
|           "requires": { |           "requires": { | ||||||
|             "pump": "^3.0.0" |             "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, |       "dev": true, | ||||||
|       "requires": { |       "requires": { | ||||||
|         "ini": "^1.3.5" |         "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": { |     "global-tunnel-ng": { | ||||||
| @@ -4325,9 +4370,9 @@ | |||||||
|       "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" |       "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" | ||||||
|     }, |     }, | ||||||
|     "ini": { |     "ini": { | ||||||
|       "version": "1.3.8", |       "version": "2.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", |       "resolved": "https://registry.npmjs.org/ini/-/ini-2.0.0.tgz", | ||||||
|       "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" |       "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==" | ||||||
|     }, |     }, | ||||||
|     "interpret": { |     "interpret": { | ||||||
|       "version": "2.2.0", |       "version": "2.2.0", | ||||||
| @@ -6072,13 +6117,23 @@ | |||||||
|         "ini": "~1.3.0", |         "ini": "~1.3.0", | ||||||
|         "minimist": "^1.2.0", |         "minimist": "^1.2.0", | ||||||
|         "strip-json-comments": "~2.0.1" |         "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": { |     "rcedit": { | ||||||
|       "version": "2.3.0", |       "version": "3.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/rcedit/-/rcedit-2.3.0.tgz", |       "resolved": "https://registry.npmjs.org/rcedit/-/rcedit-3.0.0.tgz", | ||||||
|       "integrity": "sha512-h1gNEl9Oai1oijwyJ1WYqYSXTStHnOcv1KYljg/8WM4NAg3H1KBK3azIaKkQ1WQl+d7PoJpcBMscPfLXVKgCLQ==", |       "integrity": "sha512-Zg2Ihvtfzrx8XFICzQ/4aGnhw1k4Jaba8cLvVabgpxKozO0hIIS2vqTfhRkelmOmO0XW+GvmHYO2X+TRnYNlow==", | ||||||
|       "dev": true |       "dev": true, | ||||||
|  |       "requires": { | ||||||
|  |         "cross-spawn-windows-exe": "^1.0.0" | ||||||
|  |       } | ||||||
|     }, |     }, | ||||||
|     "read-config-file": { |     "read-config-file": { | ||||||
|       "version": "6.0.0", |       "version": "6.0.0", | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ | |||||||
|     "http-proxy-agent": "4.0.1", |     "http-proxy-agent": "4.0.1", | ||||||
|     "https-proxy-agent": "5.0.0", |     "https-proxy-agent": "5.0.0", | ||||||
|     "image-type": "4.1.0", |     "image-type": "4.1.0", | ||||||
|     "ini": "1.3.8", |     "ini": "2.0.0", | ||||||
|     "is-svg": "4.2.1", |     "is-svg": "4.2.1", | ||||||
|     "jimp": "0.16.1", |     "jimp": "0.16.1", | ||||||
|     "jsdom": "^16.4.0", |     "jsdom": "^16.4.0", | ||||||
| @@ -85,7 +85,7 @@ | |||||||
|     "jasmine": "3.6.3", |     "jasmine": "3.6.3", | ||||||
|     "jsdoc": "3.6.6", |     "jsdoc": "3.6.6", | ||||||
|     "lorem-ipsum": "2.0.3", |     "lorem-ipsum": "2.0.3", | ||||||
|     "rcedit": "2.3.0", |     "rcedit": "3.0.0", | ||||||
|     "webpack": "5.10.1", |     "webpack": "5.10.1", | ||||||
|     "webpack-cli": "4.2.0" |     "webpack-cli": "4.2.0" | ||||||
|   }, |   }, | ||||||
|   | |||||||
| @@ -159,7 +159,13 @@ class Note extends Entity { | |||||||
|  |  | ||||||
|         const hash = utils.hash(this.noteId + "|" + content.toString()); |         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) { |     setJsonContent(content) { | ||||||
|   | |||||||
| @@ -122,7 +122,13 @@ class NoteRevision extends Entity { | |||||||
|  |  | ||||||
|         const hash = utils.hash(this.noteRevisionId + "|" + content); |         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() { |     beforeSaving() { | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ class NoteShort { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     addChild(childNoteId, branchId, sort = true) { |     addChild(childNoteId, branchId, sort = true) { | ||||||
|         if (!this.children.includes(childNoteId)) { |         if (!(childNoteId in this.childToBranch)) { | ||||||
|             this.children.push(childNoteId); |             this.children.push(childNoteId); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,8 +32,7 @@ function index(req, res) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function getAppCssNoteIds() { | function getAppCssNoteIds() { | ||||||
|     return (attributeService.getNotesWithLabels(['appCss', 'appTheme'])) |     return attributeService.getNoteIdsWithLabels(['appCss', 'appTheme']); | ||||||
|         .map(note => note.noteId); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|   | |||||||
| @@ -4,8 +4,8 @@ const build = require('./build'); | |||||||
| const packageJson = require('../../package'); | const packageJson = require('../../package'); | ||||||
| const {TRILIUM_DATA_DIR} = require('./data_dir'); | const {TRILIUM_DATA_DIR} = require('./data_dir'); | ||||||
|  |  | ||||||
| const APP_DB_VERSION = 176; | const APP_DB_VERSION = 177; | ||||||
| const SYNC_VERSION = 17; | const SYNC_VERSION = 18; | ||||||
| const CLIPPER_PROTOCOL_VERSION = "1.0"; | const CLIPPER_PROTOCOL_VERSION = "1.0"; | ||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
|  |  | ||||||
| const repository = require('./repository'); | const repository = require('./repository'); | ||||||
| const sql = require('./sql'); | const sql = require('./sql'); | ||||||
|  | const noteCache = require('./note_cache/note_cache'); | ||||||
| const Attribute = require('../entities/attribute'); | const Attribute = require('../entities/attribute'); | ||||||
|  |  | ||||||
| const ATTRIBUTE_TYPES = [ 'label', 'relation' ]; | 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); |           WHERE notes.isDeleted = 0 AND attributes.isDeleted = 0 AND attributes.name = ? ${valueCondition} ORDER BY position`, params); | ||||||
| } | } | ||||||
|  |  | ||||||
| function getNotesWithLabels(names) { | function getNoteIdsWithLabels(names) { | ||||||
|     const questionMarks = names.map(() => "?").join(", "); |     const noteIds = new Set(); | ||||||
|  |  | ||||||
|     return repository.getEntities(`SELECT notes.* FROM notes JOIN attributes USING(noteId)  |     for (const name of names) { | ||||||
|           WHERE notes.isDeleted = 0 AND attributes.isDeleted = 0 AND attributes.name IN (${questionMarks}) ORDER BY position`, names); |         for (const attr of noteCache.findAttributes('label', name)) { | ||||||
|  |             noteIds.add(attr.noteId); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     console.log(noteIds); | ||||||
|  |  | ||||||
|  |     return Array.from(noteIds); | ||||||
| } | } | ||||||
|  |  | ||||||
| function getNoteWithLabel(name, value) { | function getNoteWithLabel(name, value) { | ||||||
| @@ -168,7 +176,7 @@ function sanitizeAttributeName(origName) { | |||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|     getNotesWithLabel, |     getNotesWithLabel, | ||||||
|     getNotesWithLabels, |     getNoteIdsWithLabels, | ||||||
|     getNoteWithLabel, |     getNoteWithLabel, | ||||||
|     createLabel, |     createLabel, | ||||||
|     createRelation, |     createRelation, | ||||||
|   | |||||||
| @@ -35,7 +35,7 @@ class Attribute { | |||||||
|  |  | ||||||
|         this.noteCache.notes[this.noteId].ownedAttributes.push(this); |         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] = this.noteCache.attributeIndex[key] || []; | ||||||
|         this.noteCache.attributeIndex[key].push(this); |         this.noteCache.attributeIndex[key].push(this); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -119,7 +119,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED | |||||||
|             delete noteCache.attributes[attributeId]; |             delete noteCache.attributes[attributeId]; | ||||||
|  |  | ||||||
|             if (attr) { |             if (attr) { | ||||||
|                 delete noteCache.attributeIndex[`${attr.type}-${attr.name}`]; |                 delete noteCache.attributeIndex[`${attr.type}-${attr.name.toLowerCase()}`]; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         else if (attributeId in noteCache.attributes) { |         else if (attributeId in noteCache.attributes) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user