mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-27 08:16:40 +01:00 
			
		
		
		
	fix(react): note context not always updated
This commit is contained in:
		| @@ -293,7 +293,6 @@ export class ReactWrappedWidget extends BasicWidget { | |||||||
|  |  | ||||||
|     handleEvent<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null | undefined { |     handleEvent<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null | undefined { | ||||||
|         const listener = this.listeners[name]; |         const listener = this.listeners[name]; | ||||||
|         console.log("Handle ", name, listener); |  | ||||||
|         listener?.(data); |         listener?.(data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -231,19 +231,19 @@ 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>(); | ||||||
|  |  | ||||||
|     useTriliumEvent("activeContextChanged", ({ noteContext }) => { |     useTriliumEventBeta("activeContextChanged", ({ noteContext }) => { | ||||||
|         console.log("Active context changed."); |  | ||||||
|         setNoteContext(noteContext); |         setNoteContext(noteContext); | ||||||
|  |         setNotePath(noteContext.notePath); | ||||||
|     }); |     }); | ||||||
|     useTriliumEventBeta("setNoteContext", ({ noteContext }) => { |     useTriliumEventBeta("setNoteContext", ({ noteContext }) => { | ||||||
|         console.log("Set note context", noteContext, noteContext.noteId); |         console.log("Set note context", noteContext, noteContext.noteId); | ||||||
|         setNoteContext(noteContext); |         setNoteContext(noteContext); | ||||||
|     }); |     }); | ||||||
|     useTriliumEvent("noteSwitchedAndActivated", ({ noteContext }) => { |     useTriliumEventBeta("noteSwitchedAndActivated", ({ noteContext }) => { | ||||||
|         console.log("Note switched and activated") |         console.log("Note switched and activated") | ||||||
|         setNoteContext(noteContext); |         setNoteContext(noteContext); | ||||||
|     }); |     }); | ||||||
|     useTriliumEvent("noteSwitched", ({ noteContext, notePath }) => { |     useTriliumEventBeta("noteSwitched", ({ noteContext, notePath }) => { | ||||||
|         console.warn("Note switched", notePath); |         console.warn("Note switched", notePath); | ||||||
|         setNotePath(notePath); |         setNotePath(notePath); | ||||||
|     }); |     }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user