mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes
This commit is contained in:
parent
ef0941479c
commit
1d008cad13
@ -306,7 +306,9 @@ class Froca {
|
||||
*/
|
||||
async getNoteComplement(noteId) {
|
||||
if (!this.noteComplementPromises[noteId]) {
|
||||
this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row));
|
||||
this.noteComplementPromises[noteId] = server.get('notes/' + noteId)
|
||||
.then(row => new NoteComplement(row))
|
||||
.catch(e => console.error(`Cannot get note complement for note ${noteId}`));
|
||||
|
||||
// we don't want to keep large payloads forever in memory so we clean that up quite quickly
|
||||
// this cache is more meant to share the data between different components within one business transaction (e.g. loading of the note into the tab context and all the components)
|
||||
|
@ -6,7 +6,6 @@ const dateUtils = require('../../services/date_utils');
|
||||
const noteService = require('../../services/notes');
|
||||
const attributeService = require('../../services/attributes');
|
||||
const cls = require('../../services/cls');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
function getInboxNote(req) {
|
||||
const hoistedNote = getHoistedNote();
|
||||
|
@ -29,7 +29,9 @@ class Attribute extends AbstractEntity {
|
||||
/** @param {boolean} */
|
||||
this.isInheritable = !!row.isInheritable;
|
||||
|
||||
this.becca.attributes[this.attributeId] = this;
|
||||
if (this.attributeId) {
|
||||
this.becca.attributes[this.attributeId] = this;
|
||||
}
|
||||
|
||||
if (!(this.noteId in this.becca.notes)) {
|
||||
// entities can come out of order in sync, create skeleton which will be filled later
|
||||
@ -131,6 +133,8 @@ class Attribute extends AbstractEntity {
|
||||
}
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
this.becca.attributes[this.attributeId] = this;
|
||||
}
|
||||
|
||||
getPojo() {
|
||||
|
@ -81,6 +81,8 @@ class Branch extends AbstractEntity {
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
this.becca.branches[this.branchId] = this;
|
||||
}
|
||||
|
||||
getPojo() {
|
||||
|
@ -831,6 +831,36 @@ class Note extends AbstractEntity {
|
||||
.map(row => new NoteRevision(row));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string[][]} - array of notePaths (each represented by array of noteIds constituting the particular note path)
|
||||
*/
|
||||
getAllNotePaths() {
|
||||
if (this.noteId === 'root') {
|
||||
return [['root']];
|
||||
}
|
||||
|
||||
const notePaths = [];
|
||||
|
||||
for (const parentNote of this.getParentNotes()) {
|
||||
for (const parentPath of parentNote.getAllNotePaths()) {
|
||||
parentPath.push(this.noteId);
|
||||
notePaths.push(parentPath);
|
||||
}
|
||||
}
|
||||
|
||||
return notePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ancestorNoteId
|
||||
* @return {boolean} - true if ancestorNoteId occurs in at least one of the note's paths
|
||||
*/
|
||||
isDescendantOfNote(ancestorNoteId) {
|
||||
const notePaths = this.getAllNotePaths();
|
||||
|
||||
return notePaths.some(path => path.includes(ancestorNoteId));
|
||||
}
|
||||
|
||||
decrypt() {
|
||||
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
||||
try {
|
||||
@ -847,6 +877,8 @@ class Note extends AbstractEntity {
|
||||
beforeSaving() {
|
||||
super.beforeSaving();
|
||||
|
||||
this.becca.notes[this.noteId] = this;
|
||||
|
||||
this.dateModified = dateUtils.localNowDateTime();
|
||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
const noteService = require('./notes');
|
||||
const attributeService = require('./attributes');
|
||||
const dateUtils = require('./date_utils');
|
||||
const repository = require('./repository');
|
||||
const becca = require('./becca/becca');
|
||||
const sql = require('./sql');
|
||||
const protectedSessionService = require('./protected_session');
|
||||
|
||||
@ -26,10 +26,12 @@ function createNote(parentNote, noteTitle) {
|
||||
}
|
||||
|
||||
function getNoteStartingWith(parentNoteId, startsWith) {
|
||||
return repository.getEntity(`SELECT notes.* FROM notes JOIN branches USING(noteId)
|
||||
const noteId = sql.getValue(`SELECT notes.noteId FROM notes JOIN branches USING(noteId)
|
||||
WHERE parentNoteId = ? AND title LIKE '${startsWith}%'
|
||||
AND notes.isDeleted = 0 AND isProtected = 0
|
||||
AND branches.isDeleted = 0`, [parentNoteId]);
|
||||
|
||||
return becca.getNote(noteId);
|
||||
}
|
||||
|
||||
/** @return {Note} */
|
||||
|
Loading…
x
Reference in New Issue
Block a user