From 203fc3e4b2325eda4d3faaaceec29d62ecfcff7c Mon Sep 17 00:00:00 2001 From: InfiniteTF Date: Fri, 29 Jan 2021 05:00:47 +0100 Subject: [PATCH] Force reload of custom css if it's updated (#1073) --- ui/v2.5/src/components/Changelog/versions/v050.md | 1 + .../SettingsInterfacePanel.tsx | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/ui/v2.5/src/components/Changelog/versions/v050.md b/ui/v2.5/src/components/Changelog/versions/v050.md index b0db953e3..96116bc2f 100644 --- a/ui/v2.5/src/components/Changelog/versions/v050.md +++ b/ui/v2.5/src/components/Changelog/versions/v050.md @@ -7,6 +7,7 @@ * Allow configuration of visible navbar items. ### 🎨 Improvements +* Refresh UI when changing custom CSS options. * Add batch deleting of performers, tags, studios, and movies. * Reset cache after scan/clean to ensure scenes are updated. * Add more video/image resolution tags. diff --git a/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx b/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx index e561d80ed..78324213c 100644 --- a/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx +++ b/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx @@ -60,10 +60,22 @@ export const SettingsInterfacePanel: React.FC = () => { }, [config]); async function onSave() { + const prevCSS = config?.configuration.interface.css; + const prevCSSenabled = config?.configuration.interface.cssEnabled; try { const result = await updateInterfaceConfig(); // eslint-disable-next-line no-console console.log(result); + + // Force refetch of custom css if it was changed + if ( + prevCSS !== result.data?.configureInterface.css || + prevCSSenabled !== result.data?.configureInterface.cssEnabled + ) { + await fetch("/css", { cache: "reload" }); + window.location.reload(); + } + Toast.success({ content: "Updated config" }); } catch (e) { Toast.error(e);