Fixed adding more than one chat input
This commit is contained in:
parent
b6a2f7dd24
commit
d2127acf04
2 changed files with 9 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ import {
|
|||
} from "../types/zustand/flow";
|
||||
import { buildVertices } from "../utils/buildUtils";
|
||||
import {
|
||||
checkChatInput,
|
||||
cleanEdges,
|
||||
getHandleId,
|
||||
getNodeId,
|
||||
|
|
@ -228,6 +229,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
);
|
||||
},
|
||||
paste: (selection, position) => {
|
||||
if(selection.nodes.some((node) => node.data.type === "ChatInput") && checkChatInput(get().nodes)){
|
||||
useAlertStore.getState().setErrorData({title: "Error pasting components", list: ["You can only have one ChatInput component in the flow"]});
|
||||
return;
|
||||
}
|
||||
let minimumX = Infinity;
|
||||
let minimumY = Infinity;
|
||||
let idsMap = {};
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ import {
|
|||
} from "./utils";
|
||||
const uid = new ShortUniqueId({ length: 5 });
|
||||
|
||||
export function checkChatInput(nodes: Node[]) {
|
||||
return nodes.some((node) => node.data.type === "ChatInput");
|
||||
}
|
||||
|
||||
export function cleanEdges(nodes: Node[], edges: Edge[]) {
|
||||
let newEdges = cloneDeep(edges);
|
||||
edges.forEach((edge) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue