mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
refactor(react/ribbon): remove unnecessary hook
This commit is contained in:
@@ -104,33 +104,6 @@ export function useTriliumOption(name: OptionNames, needsRefresh?: boolean): [st
|
||||
]
|
||||
}
|
||||
|
||||
export function useTriliumOptionBeta(name: OptionNames, needsRefresh?: boolean): [string, (newValue: OptionValue) => Promise<void>] {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user