🐛 fix(parameterComponent): import lodash library to use _.cloneDeep function
🐛 fix(chatComponent): import lodash library to use _.cloneDeep function ✨ feat(chatComponent): add TabsContext to access tabsState and update isBuilt state based on tabsState changes
This commit is contained in:
parent
ffebce974f
commit
e4b03d7765
2 changed files with 9 additions and 7 deletions
|
|
@ -25,6 +25,7 @@ import { nodeColors } from "../../../../utils";
|
||||||
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
||||||
import { PopUpContext } from "../../../../contexts/popUpContext";
|
import { PopUpContext } from "../../../../contexts/popUpContext";
|
||||||
import ToggleShadComponent from "../../../../components/toggleShadComponent";
|
import ToggleShadComponent from "../../../../components/toggleShadComponent";
|
||||||
|
import * as _ from "lodash";
|
||||||
|
|
||||||
export default function ParameterComponent({
|
export default function ParameterComponent({
|
||||||
left,
|
left,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useContext, useEffect, useRef, useState } from "react";
|
||||||
import { useNodes } from "reactflow";
|
import { useNodes } from "reactflow";
|
||||||
import { ChatType } from "../../types/chat";
|
import { ChatType } from "../../types/chat";
|
||||||
import ChatTrigger from "./chatTrigger";
|
import ChatTrigger from "./chatTrigger";
|
||||||
|
|
@ -7,10 +7,13 @@ import BuildTrigger from "./buildTrigger";
|
||||||
import { getBuildStatus } from "../../controllers/API";
|
import { getBuildStatus } from "../../controllers/API";
|
||||||
import { NodeType } from "../../types/flow";
|
import { NodeType } from "../../types/flow";
|
||||||
import FormModal from "../../modals/formModal";
|
import FormModal from "../../modals/formModal";
|
||||||
|
import { TabsContext } from "../../contexts/tabsContext";
|
||||||
|
import * as _ from "lodash";
|
||||||
|
|
||||||
export default function Chat({ flow }: ChatType) {
|
export default function Chat({ flow }: ChatType) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [isBuilt, setIsBuilt] = useState(false);
|
const [isBuilt, setIsBuilt] = useState(false);
|
||||||
|
const {tabsState} = useContext(TabsContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
|
@ -43,21 +46,19 @@ export default function Chat({ flow }: ChatType) {
|
||||||
const prevNodesRef = useRef<any[] | undefined>();
|
const prevNodesRef = useRef<any[] | undefined>();
|
||||||
const nodes = useNodes();
|
const nodes = useNodes();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
const prevNodes = prevNodesRef.current;
|
const prevNodes = prevNodesRef.current;
|
||||||
const currentNodes = nodes.map(
|
const currentNodes = nodes.map(
|
||||||
(node: NodeType) => node.data.node.template
|
(node: NodeType) => _.cloneDeep(node.data.node.template)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
prevNodes &&
|
tabsState && tabsState[flow.id] && tabsState[flow.id].isPending
|
||||||
JSON.stringify(prevNodes) !== JSON.stringify(currentNodes)
|
&& JSON.stringify(prevNodes) !== JSON.stringify(currentNodes)
|
||||||
) {
|
) {
|
||||||
setIsBuilt(false);
|
setIsBuilt(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
prevNodesRef.current = currentNodes;
|
prevNodesRef.current = currentNodes;
|
||||||
}, [nodes]);
|
}, [tabsState]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue