Refactor: Change inputTypes and outputTypes to a only object array
This commit is contained in:
parent
9cd43802cb
commit
53629398b4
4 changed files with 18 additions and 21 deletions
|
|
@ -10,8 +10,10 @@ import { Badge } from "../ui/badge";
|
||||||
import { Textarea } from "../ui/textarea";
|
import { Textarea } from "../ui/textarea";
|
||||||
|
|
||||||
export default function IOView(): JSX.Element {
|
export default function IOView(): JSX.Element {
|
||||||
const inputIds = useFlowStore((state) => state.inputIds);
|
const inputs = useFlowStore((state) => state.inputs);
|
||||||
const outputIds = useFlowStore((state) => state.outputIds);
|
const outputs = useFlowStore((state) => state.outputs);
|
||||||
|
const inputIds = inputs.map((obj) => obj.id);
|
||||||
|
const outputIds = outputs.map((obj) => obj.id);
|
||||||
const nodes = useFlowStore((state) => state.nodes);
|
const nodes = useFlowStore((state) => state.nodes);
|
||||||
const setNode = useFlowStore((state) => state.setNode);
|
const setNode = useFlowStore((state) => state.setNode);
|
||||||
const options = inputIds.concat(outputIds);
|
const options = inputIds.concat(outputIds);
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,8 @@ export default function newChatView(): JSX.Element {
|
||||||
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
|
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
|
||||||
const {
|
const {
|
||||||
flowPool,
|
flowPool,
|
||||||
outputIds,
|
outputs,
|
||||||
inputIds,
|
inputs,
|
||||||
inputTypes,
|
|
||||||
getNode,
|
getNode,
|
||||||
setNode,
|
setNode,
|
||||||
buildFlow,
|
buildFlow,
|
||||||
|
|
@ -33,6 +32,10 @@ export default function newChatView(): JSX.Element {
|
||||||
const [lockChat, setLockChat] = useState(false);
|
const [lockChat, setLockChat] = useState(false);
|
||||||
const messagesRef = useRef<HTMLDivElement | null>(null);
|
const messagesRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
const inputTypes = inputs.map((obj) => obj.type);
|
||||||
|
const inputIds = inputs.map((obj) => obj.id);
|
||||||
|
const outputIds = outputs.map((obj) => obj.id)
|
||||||
|
|
||||||
//build chat history
|
//build chat history
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const chatOutputResponses: FlowPoolObjectType[] = [];
|
const chatOutputResponses: FlowPoolObjectType[] = [];
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,8 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
reactFlowInstance: null,
|
reactFlowInstance: null,
|
||||||
lastCopiedSelection: null,
|
lastCopiedSelection: null,
|
||||||
flowPool: {},
|
flowPool: {},
|
||||||
outputTypes: [],
|
inputs: [],
|
||||||
inputTypes: [],
|
outputs: [],
|
||||||
inputIds: [],
|
|
||||||
outputIds: [],
|
|
||||||
setFlowPool: (flowPool) => {
|
setFlowPool: (flowPool) => {
|
||||||
set({ flowPool });
|
set({ flowPool });
|
||||||
},
|
},
|
||||||
|
|
@ -68,10 +66,8 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
nodes,
|
nodes,
|
||||||
edges: newEdges,
|
edges: newEdges,
|
||||||
flowState: undefined,
|
flowState: undefined,
|
||||||
inputIds: inputs.map((input) => input.id),
|
inputs,
|
||||||
outputIds: outputs.map((output) => output.id),
|
outputs,
|
||||||
inputTypes: inputs.map((input) => input.type),
|
|
||||||
outputTypes: outputs.map((output) => output.type),
|
|
||||||
hasIO: inputs.length > 0 && outputs.length > 0,
|
hasIO: inputs.length > 0 && outputs.length > 0,
|
||||||
});
|
});
|
||||||
get().reactFlowInstance!.setViewport(viewport);
|
get().reactFlowInstance!.setViewport(viewport);
|
||||||
|
|
@ -111,10 +107,8 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
edges: newEdges,
|
edges: newEdges,
|
||||||
nodes: newChange,
|
nodes: newChange,
|
||||||
flowState: undefined,
|
flowState: undefined,
|
||||||
inputIds: inputs.map((input) => input.id),
|
inputs,
|
||||||
outputIds: outputs.map((output) => output.id),
|
outputs,
|
||||||
inputTypes: inputs.map((input) => input.type),
|
|
||||||
outputTypes: outputs.map((output) => output.type),
|
|
||||||
hasIO: inputs.length > 0 && outputs.length > 0,
|
hasIO: inputs.length > 0 && outputs.length > 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,9 @@ export type FlowPoolType = {
|
||||||
|
|
||||||
export type FlowStoreType = {
|
export type FlowStoreType = {
|
||||||
flowPool: FlowPoolType;
|
flowPool: FlowPoolType;
|
||||||
inputTypes: string[];
|
inputs: Array<{ type: string; id: string; }>;
|
||||||
outputTypes: string[];
|
outputs: Array<{ type: string; id: string; }>;
|
||||||
inputIds: string[];
|
|
||||||
hasIO: boolean;
|
hasIO: boolean;
|
||||||
outputIds: string[];
|
|
||||||
setFlowPool: (flowPool: FlowPoolType) => void;
|
setFlowPool: (flowPool: FlowPoolType) => void;
|
||||||
addDataToFlowPool: (data: any, nodeId: string) => void;
|
addDataToFlowPool: (data: any, nodeId: string) => void;
|
||||||
CleanFlowPool: () => void;
|
CleanFlowPool: () => void;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue