mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 20:54:14 +00:00
Memoize compactAdvancedJson and update deps
Wrap compactAdvancedJson in useCallback (dependent on messageApi) and add it to the dependency array of applyAdvancedJsonToBasic. This ensures a stable function reference for correct dependency tracking and avoids stale closures/unnecessary re-renders in InboundFormModal.tsx.
This commit is contained in:
parent
489a199fd4
commit
cb45febdc2
1 changed files with 3 additions and 3 deletions
|
|
@ -659,14 +659,14 @@ export default function InboundFormModal({
|
||||||
}
|
}
|
||||||
}, [messageApi]);
|
}, [messageApi]);
|
||||||
|
|
||||||
const compactAdvancedJson = (raw: string, fallback: string, label: string) => {
|
const compactAdvancedJson = useCallback((raw: string, fallback: string, label: string) => {
|
||||||
try {
|
try {
|
||||||
return JSON.stringify(JSON.parse(raw || fallback));
|
return JSON.stringify(JSON.parse(raw || fallback));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
messageApi.error(`${label} JSON invalid: ${(e as Error).message}`);
|
messageApi.error(`${label} JSON invalid: ${(e as Error).message}`);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
}, [messageApi]);
|
||||||
|
|
||||||
const applyAdvancedJsonToBasic = useCallback((): boolean => {
|
const applyAdvancedJsonToBasic = useCallback((): boolean => {
|
||||||
const ib = inboundRef.current;
|
const ib = inboundRef.current;
|
||||||
|
|
@ -888,7 +888,7 @@ export default function InboundFormModal({
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
}, [canEnableStream, t, mode, dbInbound, isFallbackHost, saveFallbacks, onSaved, onClose]);
|
}, [canEnableStream, compactAdvancedJson, t, mode, dbInbound, isFallbackHost, saveFallbacks, onSaved, onClose]);
|
||||||
|
|
||||||
const protocolSnapshot = inboundRef.current?.protocol;
|
const protocolSnapshot = inboundRef.current?.protocol;
|
||||||
const streamSnapshot = JSON.stringify(inboundRef.current?.stream?.toJson?.() || {});
|
const streamSnapshot = JSON.stringify(inboundRef.current?.stream?.toJson?.() || {});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue