feat(ui): make nodesSlice undoable

This commit is contained in:
psychedelicious
2024-05-15 16:37:13 +10:00
parent 31d8b50276
commit 27826369f0
18 changed files with 64 additions and 29 deletions

View File

@ -8,7 +8,7 @@ import { useCallback } from 'react';
import { useReactFlow } from 'reactflow';
export const useBuildNode = () => {
const nodeTemplates = useAppSelector((s) => s.nodes.templates);
const nodeTemplates = useAppSelector((s) => s.nodes.present.templates);
const flow = useReactFlow();

View File

@ -13,7 +13,7 @@ import type { Connection, Node } from 'reactflow';
export const useIsValidConnection = () => {
const store = useAppStore();
const shouldValidateGraph = useAppSelector((s) => s.nodes.shouldValidateGraph);
const shouldValidateGraph = useAppSelector((s) => s.nodes.present.shouldValidateGraph);
const isValidConnection = useCallback(
({ source, sourceHandle, target, targetHandle }: Connection): boolean => {
// Connection must have valid targets
@ -27,7 +27,7 @@ export const useIsValidConnection = () => {
}
const state = store.getState();
const { nodes, edges, templates } = state.nodes;
const { nodes, edges, templates } = state.nodes.present;
// Find the source and target nodes
const sourceNode = nodes.find((node) => node.id === source) as Node<InvocationNodeData>;