mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
avoid double rendering of note paths
This commit is contained in:
parent
e426ee3e4f
commit
51dfe8bb14
@ -69,7 +69,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
|
|||||||
this.$notePathList.empty();
|
this.$notePathList.empty();
|
||||||
|
|
||||||
if (this.noteId === 'root') {
|
if (this.noteId === 'root') {
|
||||||
await this.addPath('root');
|
await this.getRenderedPath('root');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,22 +83,18 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
|
|||||||
this.$notePathIntro.text("This note is not yet placed into the note tree.");
|
this.$notePathIntro.text("This note is not yet placed into the note tree.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const printedNotePaths = new Set();
|
const renderedPaths = [];
|
||||||
|
|
||||||
for (const notePathRecord of sortedNotePaths) {
|
for (const notePathRecord of sortedNotePaths) {
|
||||||
const notePath = notePathRecord.notePath.join('/');
|
const notePath = notePathRecord.notePath.join('/');
|
||||||
|
|
||||||
if (printedNotePaths.has(notePath)) {
|
renderedPaths.push(await this.getRenderedPath(notePath, notePathRecord));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
printedNotePaths.add(notePath);
|
|
||||||
|
|
||||||
await this.addPath(notePath, notePathRecord);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$notePathList.empty().append(...renderedPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addPath(notePath, notePathRecord) {
|
async getRenderedPath(notePath, notePathRecord) {
|
||||||
const title = await treeService.getNotePathTitle(notePath);
|
const title = await treeService.getNotePathTitle(notePath);
|
||||||
|
|
||||||
const $noteLink = await linkService.createNoteLink(notePath, {title});
|
const $noteLink = await linkService.createNoteLink(notePath, {title});
|
||||||
@ -136,7 +132,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
|
|||||||
$noteLink.append(` ${icons.join(' ')}`);
|
$noteLink.append(` ${icons.join(' ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$notePathList.append($("<li>").append($noteLink));
|
return $("<li>").append($noteLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({loadResults}) {
|
entitiesReloadedEvent({loadResults}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user