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
chore(react/type_widget): reload content on external change
Elian Doran79be13e6c7d6
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 5d5091a8ab..1667ac82fb 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -82,7 +82,7 @@ export function useEditorSpacedUpdate({ note, getData, onContentChange, dataSavedataSaved?: () => void}) {const parentComponent = useContext(ParentComponent);- const blob = useNoteBlob(note);+ const blob = useNoteBlob(note, parentComponent?.componentId);const callback = useMemo(() => {return async () => {@@ -99,6 +99,7 @@ export function useEditorSpacedUpdate({ note, getData, onContentChange, dataSave}, [ note, getData, dataSaved ])const spacedUpdate = useSpacedUpdate(callback);+ // React to note/blob changes.useEffect(() => {if (!blob) return;spacedUpdate.allowUpdateWithoutChange(() => onContentChange(blob.content));@@ -402,7 +403,7 @@ export function useNoteLabelInt(note: FNote | undefined | null, labelName: Filte]}-export function useNoteBlob(note: FNote | null | undefined): FBlob | null | undefined {+export function useNoteBlob(note: FNote | null | undefined, componentId?: string): FBlob | null | undefined {const [ blob, setBlob ] = useState<FBlob | null>();function refresh() {@@ -423,6 +424,10 @@ export function useNoteBlob(note: FNote | null | undefined): FBlob | null | undeif (loadResults.hasRevisionForNote(note.noteId)) {refresh();}++ if (loadResults.isNoteContentReloaded(note.noteId, componentId)) {+ refresh();+ }});useDebugValue(note?.noteId);