Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Only update changed config when saving settings.
nzbdav-devaf5041aa9cd5
diff --git a/frontend/app/routes/settings/route.tsx b/frontend/app/routes/settings/route.tsxindex 69d69c02..70b1a019 100644--- a/frontend/app/routes/settings/route.tsx+++ b/frontend/app/routes/settings/route.tsx@@ -103,17 +103,17 @@ function Body(props: BodyProps) {method: "POST",body: (() => {const form = new FormData();- form.append("config", JSON.stringify(newConfig));+ const changedConfig = getChangedConfig(config, newConfig);+ form.append("config", JSON.stringify(changedConfig));return form;})()});if (response.ok) {- const updatedConfig = (await response.json()).config;- setConfig(updatedConfig);+ setConfig(newConfig);}setIsSaving(false);setIsSaved(true);- }, [setIsSaving, setIsSaved, newConfig, setConfig]);+ }, [config, newConfig, setIsSaving, setIsSaved, setConfig]);return (<div className={styles.container}>@@ -149,3 +149,17 @@ function Body(props: BodyProps) {</div>);}++function getChangedConfig(+ config: Record<string, string>,+ newConfig: Record<string, string>+): Record<string, string> {+ let changedConfig: Record<string, string> = {};+ let configKeys = Object.keys(defaultConfig);+ for (const configKey of configKeys) {+ if (config[configKey] !== newConfig[configKey]) {+ changedConfig[configKey] = newConfig[configKey];+ }+ }+ return changedConfig;+}\ No newline at end of file