refactor: optimize formik value handling and improve save conditions (#7507)

* refactor: optimize formik value handling and improve save conditions

* fix
This commit is contained in:
naman-bruno
2026-03-18 14:27:58 +05:30
committed by GitHub
parent 68d80b8f78
commit 0109d72475

View File

@@ -88,31 +88,13 @@ const ProxySettings = ({ close }) => {
const [passwordVisible, setPasswordVisible] = useState(false);
useEffect(() => {
formik.setValues({
disabled: preferences.proxy.disabled || false,
inherit: preferences.proxy.inherit || false,
config: {
protocol: preferences.proxy.config?.protocol || 'http',
hostname: preferences.proxy.config?.hostname || '',
port: preferences.proxy.config?.port || '',
auth: {
disabled: preferences.proxy.config?.auth?.disabled || false,
username: preferences.proxy.config?.auth?.username || '',
password: preferences.proxy.config?.auth?.password || ''
},
bypassProxy: preferences.proxy.config?.bypassProxy || ''
}
});
}, [preferences]);
useEffect(() => {
if (formik.dirty) {
if (formik.dirty && formik.isValid) {
debouncedSave(formik.values);
}
return () => {
debouncedSave.flush();
};
}, [formik.values, formik.dirty, debouncedSave]);
}, [formik.values, formik.dirty, formik.isValid, debouncedSave]);
return (
<StyledWrapper>