mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 18:34:24 +01:00
feat(options/advanced): automatically refresh
This commit is contained in:
parent
4031332b98
commit
c4f483c250
@ -201,7 +201,7 @@ export function useTriliumOptionBool(name: OptionNames, needsRefresh?: boolean):
|
|||||||
return [
|
return [
|
||||||
(value === "true"),
|
(value === "true"),
|
||||||
(newValue) => setValue(newValue ? "true" : "false")
|
(newValue) => setValue(newValue ? "true" : "false")
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,17 +217,18 @@ export function useTriliumOptionInt(name: OptionNames): [number, (newValue: numb
|
|||||||
return [
|
return [
|
||||||
(parseInt(value, 10)),
|
(parseInt(value, 10)),
|
||||||
(newValue) => setValue(newValue)
|
(newValue) => setValue(newValue)
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link useTriliumOption}, but the object value is parsed to and from a JSON instead of a string.
|
* Similar to {@link useTriliumOption}, but the object value is parsed to and from a JSON instead of a string.
|
||||||
*
|
*
|
||||||
* @param name the name of the option to listen for.
|
* @param name the name of the option to listen for.
|
||||||
|
* @param needsRefresh whether to reload the frontend whenever the value is changed.
|
||||||
* @returns an array where the first value is the current option value and the second value is the setter.
|
* @returns an array where the first value is the current option value and the second value is the setter.
|
||||||
*/
|
*/
|
||||||
export function useTriliumOptionJson<T>(name: OptionNames): [ T, (newValue: T) => Promise<void> ] {
|
export function useTriliumOptionJson<T>(name: OptionNames, needsRefresh?: boolean): [ T, (newValue: T) => Promise<void> ] {
|
||||||
const [ value, setValue ] = useTriliumOption(name);
|
const [ value, setValue ] = useTriliumOption(name, needsRefresh);
|
||||||
useDebugValue(name);
|
useDebugValue(name);
|
||||||
return [
|
return [
|
||||||
(JSON.parse(value) as T),
|
(JSON.parse(value) as T),
|
||||||
|
|||||||
@ -158,7 +158,7 @@ function ExistingAnonymizedDatabases({ databases }: { databases: AnonymizedDbRes
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function VacuumDatabaseOptions() {
|
function VacuumDatabaseOptions() {
|
||||||
@ -175,11 +175,11 @@ function VacuumDatabaseOptions() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</OptionsSection>
|
</OptionsSection>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ExperimentalOptions() {
|
function ExperimentalOptions() {
|
||||||
const [ enabledExperimentalFeatures, setEnabledExperimentalFeatures ] = useTriliumOptionJson<string[]>("experimentalFeatures");
|
const [ enabledExperimentalFeatures, setEnabledExperimentalFeatures ] = useTriliumOptionJson<string[]>("experimentalFeatures", true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OptionsSection title={t("experimental_features.title")}>
|
<OptionsSection title={t("experimental_features.title")}>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user