mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	chore(react/type_widgets): refresh on all viewscope changes
This commit is contained in:
		| @@ -136,7 +136,7 @@ function useNoteInfo() { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     useEffect(refresh, [ actualNote, noteContext, noteContext?.viewScope?.viewMode ]); |     useEffect(refresh, [ actualNote, noteContext, noteContext?.viewScope ]); | ||||||
|     useTriliumEvent("readOnlyTemporarilyDisabled", ({ noteContext: eventNoteContext }) => { |     useTriliumEvent("readOnlyTemporarilyDisabled", ({ noteContext: eventNoteContext }) => { | ||||||
|         if (eventNoteContext?.ntxId !== noteContext?.ntxId) return; |         if (eventNoteContext?.ntxId !== noteContext?.ntxId) return; | ||||||
|         refresh(); |         refresh(); | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ import toast, { ToastOptions } from "../../services/toast"; | |||||||
| import protected_session_holder from "../../services/protected_session_holder"; | import protected_session_holder from "../../services/protected_session_holder"; | ||||||
| import server from "../../services/server"; | import server from "../../services/server"; | ||||||
| import { removeIndividualBinding } from "../../services/shortcuts"; | import { removeIndividualBinding } from "../../services/shortcuts"; | ||||||
|  | import { ViewScope } from "../../services/link"; | ||||||
|  |  | ||||||
| export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) { | export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) { | ||||||
|     const parentComponent = useContext(ParentComponent); |     const parentComponent = useContext(ParentComponent); | ||||||
| @@ -239,7 +240,7 @@ export function useNoteContext() { | |||||||
|     const [ noteContext, setNoteContext ] = useState<NoteContext>(); |     const [ noteContext, setNoteContext ] = useState<NoteContext>(); | ||||||
|     const [ notePath, setNotePath ] = useState<string | null | undefined>(); |     const [ notePath, setNotePath ] = useState<string | null | undefined>(); | ||||||
|     const [ note, setNote ] = useState<FNote | null | undefined>(); |     const [ note, setNote ] = useState<FNote | null | undefined>(); | ||||||
|     const [ , setViewMode ] = useState<string>(); |     const [ , setViewScope ] = useState<ViewScope>(); | ||||||
|     const [ refreshCounter, setRefreshCounter ] = useState(0); |     const [ refreshCounter, setRefreshCounter ] = useState(0); | ||||||
|  |  | ||||||
|     useEffect(() => { |     useEffect(() => { | ||||||
| @@ -249,7 +250,7 @@ export function useNoteContext() { | |||||||
|     useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => { |     useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => { | ||||||
|         setNoteContext(noteContext); |         setNoteContext(noteContext); | ||||||
|         setNotePath(noteContext.notePath); |         setNotePath(noteContext.notePath); | ||||||
|         setViewMode(noteContext.viewScope?.viewMode); |         setViewScope(noteContext.viewScope); | ||||||
|     }); |     }); | ||||||
|     useTriliumEvent("frocaReloaded", () => { |     useTriliumEvent("frocaReloaded", () => { | ||||||
|         setNote(noteContext?.note); |         setNote(noteContext?.note); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user