Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
toyamarinyon committed Oct 25, 2024
1 parent 139c235 commit 5de9873
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GiselleNode } from "../../../giselle-node/types";
import { giselleNodeType } from "../../../react-flow-adapter/giselle-node";
import type { CompositeAction } from "../../context";
import { addNode as addNodeInternal } from "../node";
import { setNodes } from "../node";
import { setXyFlowNodes } from "../xy-flow";

interface AddNodeInput {
Expand All @@ -12,7 +12,9 @@ export const addNode = ({
input,
}: { input: AddNodeInput }): CompositeAction => {
return (dispatch, getState) => {
dispatch(addNodeInternal({ input: { node: input.node } }));
dispatch(
setNodes({ input: { nodes: [...getState().graph.nodes, input.node] } }),
);
dispatch(
setXyFlowNodes({
input: {
Expand Down
17 changes: 1 addition & 16 deletions app/(playground)/p/[agentId]/beta-proto/graph/v2/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { GiselleNode, GiselleNodeId } from "../../giselle-node/types";

const v2NodeActionTypes = {
updateNode: "v2.updateNode",
add: "v2.addNode",
set: "v2.setNodes",
} as const;
type V2NodeActionType =
Expand All @@ -29,20 +28,6 @@ export function updateNode({
};
}

interface AddNodeAction {
type: Extract<V2NodeActionType, "v2.addNode">;
input: AddNodeInput;
}
interface AddNodeInput {
node: GiselleNode;
}
export function addNode({ input }: { input: AddNodeInput }): AddNodeAction {
return {
type: v2NodeActionTypes.add,
input,
};
}

interface SetNodesAction {
type: Extract<V2NodeActionType, "v2.setNodes">;
input: SetNodeInput;
Expand All @@ -57,7 +42,7 @@ export function setNodes({ input }: { input: SetNodeInput }) {
};
}

export type V2NodeAction = UpdateNodeAction | AddNodeAction | SetNodesAction;
export type V2NodeAction = UpdateNodeAction | SetNodesAction;

export function v2NodeReducer(
nodes: GiselleNode[],
Expand Down

0 comments on commit 5de9873

Please sign in to comment.