mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 12:44:22 +00:00
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:
parent
4242f8c881
commit
88642844d3
2 changed files with 4 additions and 2 deletions
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -524,6 +524,7 @@ export default function InboundsPage() {
|
|||
mode={formMode}
|
||||
dbInbound={formDbInbound}
|
||||
dbInbounds={dbInbounds as any[]}
|
||||
availableNodes={nodesList}
|
||||
/>
|
||||
<InboundInfoModal
|
||||
open={infoOpen}
|
||||
|
|
|
|||
Loading…
Reference in a new issue