Skip to content

Build your personal knowledge base with Trilium Notes

fix(render): not refreshing on attribute change (closes #8321)

Elian Doran9dfc1cdc4cb8
diff --git a/apps/client/src/widgets/type_widgets/Render.tsx b/apps/client/src/widgets/type_widgets/Render.tsx
index 6cc7197571..f47e58f2de 100644
--- a/apps/client/src/widgets/type_widgets/Render.tsx
+++ b/apps/client/src/widgets/type_widgets/Render.tsx
@@ -1,12 +1,15 @@
+import "./Render.css";
+
import { useEffect, useRef, useState } from "preact/hooks";
-import { TypeWidgetProps } from "./type_widget";
+
+import attributes from "../../services/attributes";
+import { t } from "../../services/i18n";
import render from "../../services/render";
-import { refToJQuerySelector } from "../react/react_utils";
import Alert from "../react/Alert";
-import "./Render.css";
-import { t } from "../../services/i18n";
-import RawHtml from "../react/RawHtml";
import { useTriliumEvent } from "../react/hooks";
+import RawHtml from "../react/RawHtml";
+import { refToJQuerySelector } from "../react/react_utils";
+import { TypeWidgetProps } from "./type_widget";
export default function Render({ note, noteContext, ntxId }: TypeWidgetProps) {
const contentRef = useRef<HTMLDivElement>(null);
@@ -31,6 +34,13 @@ export default function Render({ note, noteContext, ntxId }: TypeWidgetProps) {
refresh();
});
+ // Refresh on attribute change.
+ useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
+ if (loadResults.getAttributeRows().some(a => a.type === "relation" && a.name === "renderNote" && attributes.isAffecting(a, note))) {
+ refresh();
+ }
+ });
+
// Integration with search.
useTriliumEvent("executeWithContentElement", ({ resolve, ntxId: eventNtxId }) => {
if (eventNtxId !== ntxId) return;