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
feat(board/relation): react to column title changes
Elian Doranf820c6f23be1
diff --git a/apps/client/src/services/load_results.ts b/apps/client/src/services/load_results.tsindex 4a48757256..3e00e4a0f9 100644--- a/apps/client/src/services/load_results.ts+++ b/apps/client/src/services/load_results.ts@@ -1,11 +1,21 @@-import type { AttachmentRow, EtapiTokenRow, OptionNames } from "@triliumnext/commons";+import type { AttachmentRow, EtapiTokenRow, NoteType, OptionNames } from "@triliumnext/commons";import type { AttributeType } from "../entities/fattribute.js";import type { EntityChange } from "../server_types.js";// TODO: Deduplicate with server.interface NoteRow {+ blobId: string;+ dateCreated: string;+ dateMOdified: string;isDeleted?: boolean;+ isProtected?: boolean;+ mime: string;+ noteId: string;+ title: string;+ type: NoteType;+ utcDateCreated: string;+ utcDateModified: string;}// TODO: Deduplicate with BranchRow from `rows.ts`/diff --git a/apps/client/src/widgets/react/NoteLink.tsx b/apps/client/src/widgets/react/NoteLink.tsxindex 9e6ddc9055..758122ed0b 100644--- a/apps/client/src/widgets/react/NoteLink.tsx+++ b/apps/client/src/widgets/react/NoteLink.tsx@@ -1,6 +1,6 @@import { useEffect, useRef, useState } from "preact/hooks";import link, { ViewScope } from "../../services/link";-import { useImperativeSearchHighlighlighting } from "./hooks";+import { useImperativeSearchHighlighlighting, useTriliumEvent } from "./hooks";interface NoteLinkOpts {className?: string;@@ -19,9 +19,11 @@ interface NoteLinkOpts {export default function NoteLink({ className, notePath, showNotePath, showNoteIcon, style, noPreview, noTnLink, highlightedTokens, title, viewScope, noContextMenu }: NoteLinkOpts) {const stringifiedNotePath = Array.isArray(notePath) ? notePath.join("/") : notePath;+ const noteId = stringifiedNotePath.split("/").at(-1);const ref = useRef<HTMLSpanElement>(null);const [ jqueryEl, setJqueryEl ] = useState<JQuery<HTMLElement>>();const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);+ const [ noteTitle, setNoteTitle ] = useState<string>();useEffect(() => {link.createLink(stringifiedNotePath, {@@ -30,7 +32,7 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIcshowNoteIcon,viewScope}).then(setJqueryEl);- }, [ stringifiedNotePath, showNotePath, title, viewScope ]);+ }, [ stringifiedNotePath, showNotePath, title, viewScope, noteTitle ]);useEffect(() => {if (!ref.current || !jqueryEl) return;@@ -38,6 +40,16 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIchighlightSearch(ref.current);}, [ jqueryEl, highlightedTokens ]);+ useTriliumEvent("entitiesReloaded", ({ loadResults }) => {+ // React to note title changes, but only if the title is not overwritten.+ if (!title && noteId) {+ const entityRow = loadResults.getEntityRow("notes", noteId);+ if (entityRow) {+ setNoteTitle(entityRow.title);+ }+ }+ });+if (style) {jqueryEl?.css(style);}