chore(tabsContext.tsx): import cloneDeep function from lodash to improve code readability and maintainability
fix(tabsContext.tsx): fix comment typo fix(tabsContext.tsx): add missing semicolon to improve code consistency fix(tabsContext.tsx): clone edge data object to prevent mutation of original object refactor(PageComponent/index.tsx): remove unnecessary comment
This commit is contained in:
parent
af996b171b
commit
a9a1316183
2 changed files with 3 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import _ from "lodash";
|
import _, { cloneDeep } from "lodash";
|
||||||
import {
|
import {
|
||||||
ReactNode,
|
ReactNode,
|
||||||
createContext,
|
createContext,
|
||||||
|
|
@ -428,6 +428,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
id: source,
|
id: source,
|
||||||
});
|
});
|
||||||
sourceHandleObject.id = source;
|
sourceHandleObject.id = source;
|
||||||
|
|
||||||
edge.data.sourceHandle = sourceHandleObject;
|
edge.data.sourceHandle = sourceHandleObject;
|
||||||
const targetHandleObject: targetHandleType = scapeJSONParse(
|
const targetHandleObject: targetHandleType = scapeJSONParse(
|
||||||
edge.targetHandle!
|
edge.targetHandle!
|
||||||
|
|
@ -452,6 +453,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
sourceHandle,
|
sourceHandle,
|
||||||
targetHandle,
|
targetHandle,
|
||||||
id,
|
id,
|
||||||
|
data: cloneDeep(edge.data),
|
||||||
style: { stroke: "#555" },
|
style: { stroke: "#555" },
|
||||||
className:
|
className:
|
||||||
targetHandleObject.type === "Text"
|
targetHandleObject.type === "Text"
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,6 @@ export default function Page({
|
||||||
event.dataTransfer.getData("nodedata")
|
event.dataTransfer.getData("nodedata")
|
||||||
);
|
);
|
||||||
|
|
||||||
// If data type is not "chatInput" or if there are no "chatInputNode" nodes present in the ReactFlow instance, create a new node
|
|
||||||
// Calculate the position where the node should be created
|
// Calculate the position where the node should be created
|
||||||
const position = reactFlowInstance!.project({
|
const position = reactFlowInstance!.project({
|
||||||
x: event.clientX - reactflowBounds!.left,
|
x: event.clientX - reactflowBounds!.left,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue