From 5a0beec6cbda43af2785a5f66b662548b7304adb Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 1 Dec 2025 13:37:09 +0200 Subject: [PATCH] fix(backlinks): not refreshed after inserting a new link --- .../src/widgets/FloatingButtonsDefinitions.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx index 651f82f05..953e9469d 100644 --- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx +++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx @@ -18,6 +18,7 @@ import froca from "../services/froca"; import NoteLink from "./react/NoteLink"; import RawHtml from "./react/RawHtml"; import { ViewTypeOptions } from "./collections/interface"; +import attributes from "../services/attributes"; export interface FloatingButtonContext { parentComponent: Component; @@ -310,13 +311,24 @@ function Backlinks({ note, isDefaultViewMode }: FloatingButtonContext) { let [ popupOpen, setPopupOpen ] = useState(false); const backlinksContainerRef = useRef(null); - useEffect(() => { + function refresh() { if (!isDefaultViewMode) return; server.get(`note-map/${note.noteId}/backlink-count`).then(resp => { setBacklinkCount(resp.count); }); - }, [ note ]); + } + + useEffect(() => refresh(), [ note ]); + useTriliumEvent("entitiesReloaded", ({ loadResults }) => { + loadResults.getAttributeRows().some(attr => + attr.type === "relation" && + attr.name === "internalLink" && + attributes.isAffecting(attr, note)) + { + refresh(); + } + }); // Determine the max height of the container. const { windowHeight } = useWindowSize();