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) {
|
async getNoteComplement(noteId) {
|
||||||
if (!this.noteComplementPromises[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
|
// 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)
|
// 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 noteService = require('../../services/notes');
|
||||||
const attributeService = require('../../services/attributes');
|
const attributeService = require('../../services/attributes');
|
||||||
const cls = require('../../services/cls');
|
const cls = require('../../services/cls');
|
||||||
const repository = require('../../services/repository');
|
|
||||||
|
|
||||||
function getInboxNote(req) {
|
function getInboxNote(req) {
|
||||||
const hoistedNote = getHoistedNote();
|
const hoistedNote = getHoistedNote();
|
||||||
|
@ -29,7 +29,9 @@ class Attribute extends AbstractEntity {
|
|||||||
/** @param {boolean} */
|
/** @param {boolean} */
|
||||||
this.isInheritable = !!row.isInheritable;
|
this.isInheritable = !!row.isInheritable;
|
||||||
|
|
||||||
|
if (this.attributeId) {
|
||||||
this.becca.attributes[this.attributeId] = this;
|
this.becca.attributes[this.attributeId] = this;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(this.noteId in this.becca.notes)) {
|
if (!(this.noteId in this.becca.notes)) {
|
||||||
// entities can come out of order in sync, create skeleton which will be filled later
|
// 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();
|
super.beforeSaving();
|
||||||
|
|
||||||
|
this.becca.attributes[this.attributeId] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPojo() {
|
getPojo() {
|
||||||
|
@ -81,6 +81,8 @@ class Branch extends AbstractEntity {
|
|||||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||||
|
|
||||||
super.beforeSaving();
|
super.beforeSaving();
|
||||||
|
|
||||||
|
this.becca.branches[this.branchId] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPojo() {
|
getPojo() {
|
||||||
|
@ -831,6 +831,36 @@ class Note extends AbstractEntity {
|
|||||||
.map(row => new NoteRevision(row));
|
.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() {
|
decrypt() {
|
||||||
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
||||||
try {
|
try {
|
||||||
@ -847,6 +877,8 @@ class Note extends AbstractEntity {
|
|||||||
beforeSaving() {
|
beforeSaving() {
|
||||||
super.beforeSaving();
|
super.beforeSaving();
|
||||||
|
|
||||||
|
this.becca.notes[this.noteId] = this;
|
||||||
|
|
||||||
this.dateModified = dateUtils.localNowDateTime();
|
this.dateModified = dateUtils.localNowDateTime();
|
||||||
this.utcDateModified = dateUtils.utcNowDateTime();
|
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const noteService = require('./notes');
|
const noteService = require('./notes');
|
||||||
const attributeService = require('./attributes');
|
const attributeService = require('./attributes');
|
||||||
const dateUtils = require('./date_utils');
|
const dateUtils = require('./date_utils');
|
||||||
const repository = require('./repository');
|
const becca = require('./becca/becca');
|
||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
const protectedSessionService = require('./protected_session');
|
const protectedSessionService = require('./protected_session');
|
||||||
|
|
||||||
@ -26,10 +26,12 @@ function createNote(parentNote, noteTitle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNoteStartingWith(parentNoteId, startsWith) {
|
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}%'
|
WHERE parentNoteId = ? AND title LIKE '${startsWith}%'
|
||||||
AND notes.isDeleted = 0 AND isProtected = 0
|
AND notes.isDeleted = 0 AND isProtected = 0
|
||||||
AND branches.isDeleted = 0`, [parentNoteId]);
|
AND branches.isDeleted = 0`, [parentNoteId]);
|
||||||
|
|
||||||
|
return becca.getNote(noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Note} */
|
/** @return {Note} */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user