fix: updateObject order was incorrect
Fixes Tool nodes are not loaded correctly. #228
This commit is contained in:
parent
ed5fd7f862
commit
e27f6d5d7d
1 changed files with 206 additions and 205 deletions
|
|
@ -12,7 +12,7 @@ import { normalCaseToSnakeCase, updateObject } from "../utils";
|
||||||
import { alertContext } from "./alertContext";
|
import { alertContext } from "./alertContext";
|
||||||
import { typesContext } from "./typesContext";
|
import { typesContext } from "./typesContext";
|
||||||
import { TemplateVariableType } from "../types/api";
|
import { TemplateVariableType } from "../types/api";
|
||||||
const { v4: uuidv4 } = require('uuid');
|
const { v4: uuidv4 } = require("uuid");
|
||||||
|
|
||||||
const TabsContextInitialValue: TabsContextType = {
|
const TabsContextInitialValue: TabsContextType = {
|
||||||
save: () => {},
|
save: () => {},
|
||||||
|
|
@ -63,12 +63,13 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
let cookieObject: LangFlowState = JSON.parse(cookie);
|
let cookieObject: LangFlowState = JSON.parse(cookie);
|
||||||
cookieObject.flows.forEach((flow) => {
|
cookieObject.flows.forEach((flow) => {
|
||||||
flow.data.nodes.forEach((node) => {
|
flow.data.nodes.forEach((node) => {
|
||||||
if (Object.keys(templates[node.data.type]["template"]).length>0) {
|
if (Object.keys(templates[node.data.type]["template"]).length > 0) {
|
||||||
node.data.node.template = updateObject(
|
node.data.node.template = updateObject(
|
||||||
node.data.node.template as TemplateVariableType,
|
|
||||||
templates[node.data.type][
|
templates[node.data.type][
|
||||||
"template"
|
"template"
|
||||||
] as unknown as TemplateVariableType
|
] as unknown as TemplateVariableType,
|
||||||
|
|
||||||
|
node.data.node.template as TemplateVariableType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -127,12 +128,12 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
// parse the text into a JSON object
|
// parse the text into a JSON object
|
||||||
let flow: FlowType = JSON.parse(text);
|
let flow: FlowType = JSON.parse(text);
|
||||||
flow.data.nodes.forEach((node) => {
|
flow.data.nodes.forEach((node) => {
|
||||||
if (Object.keys(templates[node.data.type]["template"]).length>0) {
|
if (Object.keys(templates[node.data.type]["template"]).length > 0) {
|
||||||
node.data.node.template = updateObject(
|
node.data.node.template = updateObject(
|
||||||
node.data.node.template as TemplateVariableType,
|
|
||||||
templates[node.data.type][
|
templates[node.data.type][
|
||||||
"template"
|
"template"
|
||||||
] as unknown as TemplateVariableType
|
] as unknown as TemplateVariableType,
|
||||||
|
node.data.node.template as TemplateVariableType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue