From e7931bf3606ea398edc568cbd361cc0d6b13c69e Mon Sep 17 00:00:00 2001 From: Athou Date: Fri, 5 May 2023 14:47:15 +0200 Subject: [PATCH] call reload() only once --- .../src/components/settings/CustomCss.tsx | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/commafeed-client/src/components/settings/CustomCss.tsx b/commafeed-client/src/components/settings/CustomCss.tsx index 13097855..1d9e9e6a 100644 --- a/commafeed-client/src/components/settings/CustomCss.tsx +++ b/commafeed-client/src/components/settings/CustomCss.tsx @@ -20,11 +20,17 @@ export function CustomCss() { const form = useForm() const { setValues } = form - const saveCustomCss = useAsyncCallback(client.user.saveSettings, { - onSuccess: () => { - window.location.reload() + const saveCustomCss = useAsyncCallback( + async (d: FormData) => { + if (!settings) return + await client.user.saveSettings({ ...settings, customCss: d.customCss }) }, - }) + { + onSuccess: () => { + window.location.reload() + }, + } + ) useEffect(() => { if (!customCss) return @@ -34,17 +40,7 @@ export function CustomCss() { }, [setValues, customCss]) return ( -
{ - if (!settings) return - saveCustomCss - .execute({ - ...settings, - customCss: data.customCss, - }) - .then(() => window.location.reload()) - })} - > +