diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index bc5e7a8e7..9a688c10e 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -1090,7 +1090,7 @@ export function useNoteTitle(noteId: string | undefined, parentNoteId: string | const [ title, setTitle ] = useState(); const requestIdRef = useRef(0); - useEffect(() => { + const refresh = useCallback(() => { const requestId = ++requestIdRef.current; if (!noteId) return; tree.getNoteTitle(noteId, parentNoteId).then(title => { @@ -1099,6 +1099,15 @@ export function useNoteTitle(noteId: string | undefined, parentNoteId: string | }); }, [ noteId, parentNoteId ]); + useEffect(() => { + refresh(); + }, [ refresh ]); + + // React to changes in protected session. + useTriliumEvent("protectedSessionStarted", () => { + refresh(); + }); + return title; }