chore: release version v1.12.6

This commit is contained in:
Dmitry Popov
2024-10-24 21:12:13 +02:00
parent a81f06b743
commit b6bb4647c7

View File

@@ -2,27 +2,22 @@ import { Node, useReactFlow } from 'reactflow';
import { useCallback, useRef } from 'react';
import { CommandAddSystems } from '@/hooks/Mapper/types/mapHandlers.ts';
import { convertSystem2Node } from '../../helpers';
import { useMapState } from '@/hooks/Mapper/components/map/MapProvider.tsx';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
export const useMapAddSystems = () => {
const rf = useReactFlow();
const {
data: { systems },
update,
} = useMapState();
} = useMapRootState();
const ref = useRef({ rf, systems, update });
ref.current = { update, systems, rf };
const ref = useRef({ rf, systems });
ref.current = { systems, rf };
return useCallback(
(systems: CommandAddSystems) => {
const nodes = rf.getNodes();
const prepared: Node[] = systems.filter(x => !nodes.some(y => x.id === y.id)).map(convertSystem2Node);
rf.addNodes(prepared);
ref.current.update({
systems: [...ref.current.systems.filter(sys => systems.some(x => sys.id !== x.id)), ...systems],
});
},
[rf],
);