mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
note short can lazy load note content
This commit is contained in:
parent
50a0400616
commit
e828ef370d
@ -8,7 +8,6 @@ const RELATION_DEFINITION = 'relation-definition';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This note's representation is used in note tree and is kept in TreeCache.
|
* This note's representation is used in note tree and is kept in TreeCache.
|
||||||
* Its notable omission is the note content.
|
|
||||||
*/
|
*/
|
||||||
class NoteShort {
|
class NoteShort {
|
||||||
constructor(treeCache, row) {
|
constructor(treeCache, row) {
|
||||||
@ -25,6 +24,7 @@ class NoteShort {
|
|||||||
this.mime = row.mime;
|
this.mime = row.mime;
|
||||||
/** @param {boolean} */
|
/** @param {boolean} */
|
||||||
this.archived = row.archived;
|
this.archived = row.archived;
|
||||||
|
/** @param {string} */
|
||||||
this.cssClass = row.cssClass;
|
this.cssClass = row.cssClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +33,26 @@ class NoteShort {
|
|||||||
return this.mime === "application/json";
|
return this.mime === "application/json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getContent() {
|
||||||
|
// we're not caching content since these objects are in treeCache and as such pretty long lived
|
||||||
|
const note = await server.get("notes/" + this.noteId);
|
||||||
|
|
||||||
|
return note.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getJsonContent() {
|
||||||
|
const content = await this.getContent();
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(content);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(`Cannot parse content of note ${this.noteId}: `, e.message);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Branch[]>} */
|
/** @returns {Promise<Branch[]>} */
|
||||||
async getBranches() {
|
async getBranches() {
|
||||||
const branchIds = this.treeCache.parents[this.noteId].map(
|
const branchIds = this.treeCache.parents[this.noteId].map(
|
||||||
|
@ -33,6 +33,7 @@ const BUILTIN_ATTRIBUTES = [
|
|||||||
{ type: 'relation', name: 'runOnAttributeCreation', isDangerous: true },
|
{ type: 'relation', name: 'runOnAttributeCreation', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnAttributeChange', isDangerous: true },
|
{ type: 'relation', name: 'runOnAttributeChange', isDangerous: true },
|
||||||
{ type: 'relation', name: 'template' },
|
{ type: 'relation', name: 'template' },
|
||||||
|
{ type: 'relation', name: 'widget', isDangerous: true },
|
||||||
{ type: 'relation', name: 'renderNote', isDangerous: true }
|
{ type: 'relation', name: 'renderNote', isDangerous: true }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user