Skip to content

Build your personal knowledge base with Trilium Notes

feat(book_properties): react to external changes

Elian Doran2d11ed805dea
diff --git a/apps/client/src/widgets/ribbon_widgets/book_properties.ts b/apps/client/src/widgets/ribbon_widgets/book_properties.ts
index 5a2c9d3246..c48fc6d6b3 100644
--- a/apps/client/src/widgets/ribbon_widgets/book_properties.ts
+++ b/apps/client/src/widgets/ribbon_widgets/book_properties.ts
@@ -70,6 +70,7 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
private $expandChildrenButton!: JQuery<HTMLElement>;
private $collapseAllButton!: JQuery<HTMLElement>;
private $propertiesContainer!: JQuery<HTMLElement>;
+ private labelsToWatch: string[] = [];
get name() {
return "bookProperties";
@@ -146,6 +147,7 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
if (bookPropertiesData) {
for (const property of bookPropertiesData.properties) {
this.$propertiesContainer.append(renderBookProperty(property, note));
+ this.labelsToWatch.push(property.bindToLabel);
}
}
}
@@ -163,7 +165,9 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
}
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
- if (loadResults.getAttributeRows().find((attr) => attr.noteId === this.noteId && attr.name === "viewType")) {
+ if (loadResults.getAttributeRows().find((attr) =>
+ attr.noteId === this.noteId
+ && (attr.name === "viewType" || this.labelsToWatch.includes(attr.name ?? "")))) {
this.refresh();
}
}