perf(inbounds): share nodes list with form modal instead of refetching

InboundsPage and InboundFormModal both called useNodes() — each
instance maintains its own state and fires its own /panel/api/nodes/list
fetch on mount. Since the modal is always rendered (open or not), every
page load hit the endpoint twice.

Threaded nodes from the page through an availableNodes prop on the form
modal so they share one fetch.
This commit is contained in:
MHSanaei 2026-05-23 17:32:58 +02:00
parent 4242f8c881
commit 88642844d3
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
2 changed files with 4 additions and 2 deletions

View file

@ -60,7 +60,7 @@ import { DBInbound } from '@/models/dbinbound.js';
import FinalMaskForm from '@/components/FinalMaskForm';
import DateTimePicker from '@/components/DateTimePicker';
import JsonEditor from '@/components/JsonEditor';
import { useNodes, type NodeRecord } from '@/hooks/useNodes';
import type { NodeRecord } from '@/hooks/useNodes';
import './InboundFormModal.css';
const { TextArea } = Input;
@ -73,6 +73,7 @@ interface InboundFormModalProps {
mode: 'add' | 'edit';
dbInbound: any;
dbInbounds: any[];
availableNodes?: NodeRecord[];
}
const TRAFFIC_RESETS = ['never', 'hourly', 'daily', 'weekly', 'monthly'];
@ -156,10 +157,10 @@ export default function InboundFormModal({
mode,
dbInbound,
dbInbounds,
availableNodes,
}: InboundFormModalProps) {
const { t } = useTranslation();
const [messageApi, messageContextHolder] = message.useMessage();
const { nodes: availableNodes } = useNodes();
const selectableNodes = useMemo(
() => (availableNodes || []).filter((n: NodeRecord) => n.enable),
[availableNodes],

View file

@ -524,6 +524,7 @@ export default function InboundsPage() {
mode={formMode}
dbInbound={formDbInbound}
dbInbounds={dbInbounds as any[]}
availableNodes={nodesList}
/>
<InboundInfoModal
open={infoOpen}