From 88642844d37fc300244e4c68849cd54137112901 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 23 May 2026 17:32:58 +0200 Subject: [PATCH] perf(inbounds): share nodes list with form modal instead of refetching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend/src/pages/inbounds/InboundFormModal.tsx | 5 +++-- frontend/src/pages/inbounds/InboundsPage.tsx | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/inbounds/InboundFormModal.tsx b/frontend/src/pages/inbounds/InboundFormModal.tsx index 2eaaa852..6c7213ec 100644 --- a/frontend/src/pages/inbounds/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/InboundFormModal.tsx @@ -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], diff --git a/frontend/src/pages/inbounds/InboundsPage.tsx b/frontend/src/pages/inbounds/InboundsPage.tsx index 98795f91..27323fe4 100644 --- a/frontend/src/pages/inbounds/InboundsPage.tsx +++ b/frontend/src/pages/inbounds/InboundsPage.tsx @@ -524,6 +524,7 @@ export default function InboundsPage() { mode={formMode} dbInbound={formDbInbound} dbInbounds={dbInbounds as any[]} + availableNodes={nodesList} />