always keep all the ancestors in the cache WIP

This commit is contained in:
zadam 2020-03-18 22:42:29 +01:00
parent 4a89df7ebf
commit 48c57c7ce7
13 changed files with 28 additions and 28 deletions

View File

@ -407,7 +407,7 @@ class NoteShort {
* @returns {Promise<NoteShort[]>} * @returns {Promise<NoteShort[]>}
*/ */
async getRelationTargets(name) { async getRelationTargets(name) {
const relations = await this.getRelations(name); const relations = this.getRelations(name);
const targets = []; const targets = [];
for (const relation of relations) { for (const relation of relations) {
@ -446,8 +446,8 @@ class NoteShort {
return dto; return dto;
} }
async getCssClass() { getCssClass() {
const labels = await this.getLabels('cssClass'); const labels = this.getLabels('cssClass');
return labels.map(l => l.value).join(' '); return labels.map(l => l.value).join(' ');
} }
} }

View File

@ -77,7 +77,7 @@ async function getRenderedContent(note) {
$rendered = $("<em>Content of this note cannot be displayed in the book format</em>"); $rendered = $("<em>Content of this note cannot be displayed in the book format</em>");
} }
$rendered.addClass(await note.getCssClass()); $rendered.addClass(note.getCssClass());
return { return {
renderedContent: $rendered, renderedContent: $rendered,

View File

@ -2,7 +2,7 @@ import server from "./server.js";
import bundleService from "./bundle.js"; import bundleService from "./bundle.js";
async function render(note, $el) { async function render(note, $el) {
const relations = await note.getRelations('renderNote'); const relations = note.getRelations('renderNote');
const renderNoteIds = relations const renderNoteIds = relations
.map(rel => rel.value) .map(rel => rel.value)
.filter(noteId => noteId); .filter(noteId => noteId);

View File

@ -40,16 +40,16 @@ const NOTE_TYPE_ICONS = {
"book": "bx bx-book" "book": "bx bx-book"
}; };
async function getIconClass(note) { function getIconClass(note) {
const labels = await note.getLabels('iconClass'); const labels = note.getLabels('iconClass');
return labels.map(l => l.value).join(' '); return labels.map(l => l.value).join(' ');
} }
async function getIcon(note) { function getIcon(note) {
const hoistedNoteId = hoistedNoteService.getHoistedNoteId(); const hoistedNoteId = hoistedNoteService.getHoistedNoteId();
const iconClass = await getIconClass(note); const iconClass = getIconClass(note);
if (iconClass) { if (iconClass) {
return iconClass; return iconClass;
@ -90,8 +90,8 @@ async function prepareNode(branch) {
isProtected: note.isProtected, isProtected: note.isProtected,
noteType: note.type, noteType: note.type,
title: utils.escapeHtml(title), title: utils.escapeHtml(title),
extraClasses: await getExtraClasses(note), extraClasses: getExtraClasses(note),
icon: await getIcon(note), icon: getIcon(note),
refKey: note.noteId, refKey: note.noteId,
expanded: branch.isExpanded || hoistedNoteId === note.noteId, expanded: branch.isExpanded || hoistedNoteId === note.noteId,
lazy: true, lazy: true,
@ -134,7 +134,7 @@ async function prepareSearchBranch(note) {
return await prepareRealBranch(newNote); return await prepareRealBranch(newNote);
} }
async function getExtraClasses(note) { function getExtraClasses(note) {
utils.assertArguments(note); utils.assertArguments(note);
const extraClasses = []; const extraClasses = [];
@ -147,7 +147,7 @@ async function getExtraClasses(note) {
extraClasses.push("multiple-parents"); extraClasses.push("multiple-parents");
} }
const cssClass = await note.getCssClass(); const cssClass = note.getCssClass();
if (cssClass) { if (cssClass) {
extraClasses.push(cssClass); extraClasses.push(cssClass);
@ -159,7 +159,7 @@ async function getExtraClasses(note) {
extraClasses.push(utils.getMimeTypeClass(note.mime)); extraClasses.push(utils.getMimeTypeClass(note.mime));
} }
if (await note.hasLabel('archived')) { if (note.hasLabel('archived')) {
extraClasses.push("archived"); extraClasses.push("archived");
} }

View File

@ -20,7 +20,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
async refreshWithNote(note) { async refreshWithNote(note) {
// remember which title was when we found the similar notes // remember which title was when we found the similar notes
this.title = note.title; this.title = note.title;
let editedNotes = await server.get('edited-notes/' + await note.getLabelValue("dateNote")); let editedNotes = await server.get('edited-notes/' + note.getLabelValue("dateNote"));
editedNotes = editedNotes.filter(n => n.noteId !== note.noteId); editedNotes = editedNotes.filter(n => n.noteId !== note.noteId);

View File

@ -135,7 +135,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
const note = this.note; const note = this.note;
if (note) { if (note) {
note.getCssClass().then(cssClass => this.$widget.addClass(cssClass)); this.$widget.addClass(note.getCssClass());
this.$widget.addClass(utils.getNoteTypeClass(note.type)); this.$widget.addClass(utils.getNoteTypeClass(note.type));
this.$widget.addClass(utils.getMimeTypeClass(note.mime)); this.$widget.addClass(utils.getMimeTypeClass(note.mime));

View File

@ -343,7 +343,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
await parentNode.setExpanded(true, expandOpts); await parentNode.setExpanded(true, expandOpts);
} }
await this.updateNode(parentNode); this.updateNode(parentNode);
let foundChildNode = this.findChildNode(parentNode, childNoteId); let foundChildNode = this.findChildNode(parentNode, childNoteId);
@ -384,15 +384,15 @@ export default class NoteTreeWidget extends TabAwareWidget {
return this.getNodeFromPath(notePath, true, expandOpts); return this.getNodeFromPath(notePath, true, expandOpts);
} }
async updateNode(node) { updateNode(node) {
const note = treeCache.getNoteFromCache(node.data.noteId); const note = treeCache.getNoteFromCache(node.data.noteId);
const branch = treeCache.getBranch(node.data.branchId); const branch = treeCache.getBranch(node.data.branchId);
node.data.isProtected = note.isProtected; node.data.isProtected = note.isProtected;
node.data.noteType = note.type; node.data.noteType = note.type;
node.folder = note.type === 'search' || note.getChildNoteIds().length > 0; node.folder = note.type === 'search' || note.getChildNoteIds().length > 0;
node.icon = await treeBuilder.getIcon(note); node.icon = treeBuilder.getIcon(note);
node.extraClasses = await treeBuilder.getExtraClasses(note); node.extraClasses = treeBuilder.getExtraClasses(note);
node.title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title; node.title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
node.renderTitle(); node.renderTitle();
} }
@ -526,13 +526,13 @@ export default class NoteTreeWidget extends TabAwareWidget {
for (const node of this.getNodesByNoteId(noteId)) { for (const node of this.getNodesByNoteId(noteId)) {
await node.load(true); await node.load(true);
await this.updateNode(node); this.updateNode(node);
} }
} }
for (const noteId of noteIdsToUpdate) { for (const noteId of noteIdsToUpdate) {
for (const node of this.getNodesByNoteId(noteId)) { for (const node of this.getNodesByNoteId(noteId)) {
await this.updateNode(node); this.updateNode(node);
} }
} }

View File

@ -38,7 +38,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
async refreshWithNote(note) { async refreshWithNote(note) {
this.$container.empty(); this.$container.empty();
const attributes = await note.getAttributes(); const attributes = note.getAttributes();
const promoted = attributes.filter(attr => const promoted = attributes.filter(attr =>
(attr.type === 'label-definition' || attr.type === 'relation-definition') (attr.type === 'label-definition' || attr.type === 'relation-definition')

View File

@ -612,7 +612,7 @@ export default class TabRowWidget extends BasicWidget {
} }
} }
note.getCssClass().then(cssClass => $tab.addClass(cssClass)); $tab.addClass(note.getCssClass());
$tab.addClass(utils.getNoteTypeClass(note.type)); $tab.addClass(utils.getNoteTypeClass(note.type));
$tab.addClass(utils.getMimeTypeClass(note.mime)); $tab.addClass(utils.getMimeTypeClass(note.mime));
} }

View File

@ -145,7 +145,7 @@ export default class BookTypeWidget extends TypeWidget {
.append(' if you want to add some text.')); .append(' if you want to add some text.'));
} }
const zoomLevel = parseInt(await note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel(); const zoomLevel = parseInt(note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();
this.setZoom(zoomLevel); this.setZoom(zoomLevel);
await this.renderIntoElement(note, this.$content); await this.renderIntoElement(note, this.$content);

View File

@ -99,7 +99,7 @@ export default class FileTypeWidget extends TypeWidget {
} }
async doRefresh(note) { async doRefresh(note) {
const attributes = await note.getAttributes(); const attributes = note.getAttributes();
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]); const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
this.$widget.show(); this.$widget.show();

View File

@ -112,7 +112,7 @@ class ImageTypeWidget extends TypeWidget {
} }
async doRefresh(note) { async doRefresh(note) {
const attributes = await note.getAttributes(); const attributes = note.getAttributes();
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]); const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
this.$widget.show(); this.$widget.show();

View File

@ -141,7 +141,7 @@ export default class TextTypeWidget extends TypeWidget {
} }
async doRefresh(note) { async doRefresh(note) {
this.textEditor.isReadOnly = await note.hasLabel('readOnly'); this.textEditor.isReadOnly = note.hasLabel('readOnly');
const noteComplement = await treeCache.getNoteComplement(note.noteId); const noteComplement = await treeCache.getNoteComplement(note.noteId);