diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 1af5485b3..885049b9c 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -67,12 +67,24 @@ export function useSpacedUpdate(callback: () => Promise, interval = 1000) return spacedUpdateRef.current; } -export function useTriliumOption(name: OptionNames): [string, Dispatch>] { +export function useTriliumOption(name: OptionNames): [string, (newValue: string) => void] { const initialValue = options.get(name); const [ value, setValue ] = useState(initialValue); + function wrappedSetValue(newValue: string) { + options.save(name, newValue); + }; + + useTriliumEvent("entitiesReloaded", ({ loadResults }) => { + if (loadResults.getOptionNames().includes(name)) { + const newValue = options.get(name); + console.log("Got entities reloaded for option ", name, "value", newValue); + setValue(newValue); + } + }); + return [ value, - setValue + wrappedSetValue ] } \ No newline at end of file diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx index ee95e15b1..f3f48827f 100644 --- a/apps/client/src/widgets/type_widgets/options/appearance.tsx +++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx @@ -5,6 +5,7 @@ import OptionsSection from "./components/OptionsSection"; export default function AppearanceSettings() { const [ layoutOrientation, setLayoutOrientation ] = useTriliumOption("layoutOrientation"); + console.log("Render with ", layoutOrientation); return (