diff --git a/commafeed-client/index.html b/commafeed-client/index.html index b31c73fb..fca20ffa 100644 --- a/commafeed-client/index.html +++ b/commafeed-client/index.html @@ -11,5 +11,6 @@
+ diff --git a/commafeed-client/src/app/types.ts b/commafeed-client/src/app/types.ts index 4b7a3080..a06e8b8c 100644 --- a/commafeed-client/src/app/types.ts +++ b/commafeed-client/src/app/types.ts @@ -231,6 +231,7 @@ export interface Settings { showRead: boolean scrollMarks: boolean customCss?: string + customJs?: string scrollSpeed: number sharingSettings: SharingSettings } diff --git a/commafeed-client/src/components/settings/CustomCss.tsx b/commafeed-client/src/components/settings/CustomCodeSettings.tsx similarity index 60% rename from commafeed-client/src/components/settings/CustomCss.tsx rename to commafeed-client/src/components/settings/CustomCodeSettings.tsx index 90c1ac09..5d9e06b3 100644 --- a/commafeed-client/src/components/settings/CustomCss.tsx +++ b/commafeed-client/src/components/settings/CustomCodeSettings.tsx @@ -11,20 +11,24 @@ import { TbDeviceFloppy } from "react-icons/tb" interface FormData { customCss: string + customJs: string } -export function CustomCss() { +export function CustomCodeSettings() { const settings = useAppSelector(state => state.user.settings) - const customCss = settings?.customCss const dispatch = useAppDispatch() const form = useForm() const { setValues } = form - const saveCustomCss = useAsyncCallback( + const saveCustomCode = useAsyncCallback( async (d: FormData) => { if (!settings) return - await client.user.saveSettings({ ...settings, customCss: d.customCss }) + await client.user.saveSettings({ + ...settings, + customCss: d.customCss, + customJs: d.customJs, + }) }, { onSuccess: () => { @@ -34,25 +38,27 @@ export function CustomCss() { ) useEffect(() => { - if (!customCss) return + if (!settings) return setValues({ - customCss, + customCss: settings.customCss, + customJs: settings.customJs, }) - }, [setValues, customCss]) + }, [setValues, settings]) return ( <> - {saveCustomCss.error && ( + {saveCustomCode.error && ( - + )} -
+