Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(backlinks): not refreshed after inserting a new link
Elian Doran5a0beec6cbda
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsxindex 651f82f059..953e9469d5 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<HTMLDivElement>(null);- useEffect(() => {+ function refresh() {if (!isDefaultViewMode) return;server.get<BacklinkCountResponse>(`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();