mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 12:44:22 +00:00
fix(xray): clear dirty state after saving unchanged config
Editing an outbound and re-saving it without real changes left the top Save button stuck enabled, and clicking it never cleared it. The form re-normalizes values into deeply-equal config, so react-query keeps the same configQuery.data reference on refetch and the seed effect that resets the dirty baseline never re-runs. Advance the baseline to the persisted value in saveMut.onSuccess instead of relying solely on the refetch.
This commit is contained in:
parent
7bc31dd194
commit
b9612f1326
1 changed files with 15 additions and 7 deletions
|
|
@ -197,13 +197,21 @@ export function useXraySetting(): UseXraySettingResult {
|
||||||
}, [queryClient]);
|
}, [queryClient]);
|
||||||
|
|
||||||
const saveMut = useMutation({
|
const saveMut = useMutation({
|
||||||
mutationFn: async () =>
|
mutationFn: async () => {
|
||||||
HttpUtil.post('/panel/xray/update', {
|
const sentXraySetting = xraySettingRef.current;
|
||||||
xraySetting: xraySettingRef.current,
|
const sentTestUrl = outboundTestUrlRef.current || DEFAULT_TEST_URL;
|
||||||
outboundTestUrl: outboundTestUrlRef.current || DEFAULT_TEST_URL,
|
const msg = await HttpUtil.post('/panel/xray/update', {
|
||||||
}),
|
xraySetting: sentXraySetting,
|
||||||
onSuccess: (msg) => {
|
outboundTestUrl: sentTestUrl,
|
||||||
if (msg?.success) queryClient.invalidateQueries({ queryKey: keys.xray.config() });
|
});
|
||||||
|
return { msg, sentXraySetting, sentTestUrl };
|
||||||
|
},
|
||||||
|
onSuccess: ({ msg, sentXraySetting, sentTestUrl }) => {
|
||||||
|
if (!msg?.success) return;
|
||||||
|
oldXraySettingRef.current = sentXraySetting;
|
||||||
|
oldOutboundTestUrlRef.current = sentTestUrl;
|
||||||
|
setSaveDisabled(true);
|
||||||
|
queryClient.invalidateQueries({ queryKey: keys.xray.config() });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue