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:
MHSanaei 2026-06-02 02:08:06 +02:00
parent 7bc31dd194
commit b9612f1326
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A

View file

@ -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() });
}, },
}); });