From ccda623840030cbb3ac7a76b6fb12d2753361861 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 25 Aug 2025 10:32:11 +0300 Subject: [PATCH] refactor(react/ribbon): remove unnecessary hook --- apps/client/src/widgets/react/hooks.tsx | 27 ------------------- .../src/widgets/ribbon/BasicPropertiesTab.tsx | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 8071c962e..b4059ebfe 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -104,33 +104,6 @@ export function useTriliumOption(name: OptionNames, needsRefresh?: boolean): [st ] } -export function useTriliumOptionBeta(name: OptionNames, needsRefresh?: boolean): [string, (newValue: OptionValue) => Promise] { - const initialValue = options.get(name); - const [ value, setValue ] = useState(initialValue); - - const wrappedSetValue = useMemo(() => { - return async (newValue: OptionValue) => { - await options.save(name, newValue); - - if (needsRefresh) { - reloadFrontendApp(`option change: ${name}`); - } - } - }, [ name, needsRefresh ]); - - useTriliumEvent("entitiesReloaded", useCallback(({ loadResults }) => { - if (loadResults.getOptionNames().includes(name)) { - const newValue = options.get(name); - setValue(newValue); - } - }, [ name ])); - - return [ - value, - wrappedSetValue - ] -} - /** * Similar to {@link useTriliumOption}, but the value is converted to and from a boolean instead of a string. * diff --git a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx index 623324d52..45d6d3999 100644 --- a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx +++ b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx @@ -267,7 +267,7 @@ function SharedSwitch({ note }: { note?: FNote | null }) { } function NoteLanguageSwitch({ note }: { note?: FNote | null }) { - const [ languages ] = useTriliumOptionBeta("languages"); + const [ languages ] = useTriliumOption("languages"); const DEFAULT_LOCALE = { id: "", name: t("note_language.not_set")