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[]>}
*/
async getRelationTargets(name) {
const relations = await this.getRelations(name);
const relations = this.getRelations(name);
const targets = [];
for (const relation of relations) {
@ -446,8 +446,8 @@ class NoteShort {
return dto;
}
async getCssClass() {
const labels = await this.getLabels('cssClass');
getCssClass() {
const labels = this.getLabels('cssClass');
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.addClass(await note.getCssClass());
$rendered.addClass(note.getCssClass());
return {
renderedContent: $rendered,

View File

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

View File

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

View File

@ -20,7 +20,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
async refreshWithNote(note) {
// remember which title was when we found the similar notes
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);

View File

@ -135,7 +135,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
const note = this.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.getMimeTypeClass(note.mime));

View File

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

View File

@ -145,7 +145,7 @@ export default class BookTypeWidget extends TypeWidget {
.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);
await this.renderIntoElement(note, this.$content);

View File

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

View File

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

View File

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