Skip to content

Commit

Permalink
removed circular depedency
Browse files Browse the repository at this point in the history
  • Loading branch information
vsvamsi1 committed Jan 22, 2025
1 parent 1b27128 commit 2b46cd0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/client/src/workers/Evaluation/handlers/evalTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
import type { MetaWidgetsReduxState } from "reducers/entityReducers/metaWidgetsReducer";
import type { Attributes } from "instrumentation/types";
import { updateActionsToEvalTree } from "./updateActionData";
import { updateActionsToEvalTree } from "./updateActionsToEvalTree";

// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
30 changes: 1 addition & 29 deletions app/client/src/workers/Evaluation/handlers/updateActionData.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { dataTreeEvaluator } from "./evalTree";
import type { EvalWorkerSyncRequest } from "../types";
import set from "lodash/set";
import { evalTreeWithChanges } from "../evalTreeWithChanges";
import DataStore from "../dataStore";
import { EVAL_WORKER_SYNC_ACTION } from "ee/workers/Evaluation/evalWorkerActions";
import type { DataTree } from "entities/DataTree/dataTreeTypes";
import { updateActionsToEvalTree } from "./updateActionsToEvalTree";

export interface UpdateActionProps {
entityName: string;
Expand Down Expand Up @@ -43,29 +41,3 @@ export function handleActionsDataUpdate(actionsToUpdate: UpdateActionProps[]) {
webworkerTelemetry: {},
});
}

export function updateActionsToEvalTree(
evalTree: DataTree,
actionsToUpdate?: UpdateActionProps[],
) {
if (!actionsToUpdate) return;

for (const actionToUpdate of actionsToUpdate) {
const { dataPath, dataPathRef, entityName } = actionToUpdate;
let { data } = actionToUpdate;

if (dataPathRef) {
data = DataStore.getActionData(dataPathRef);
DataStore.deleteActionData(dataPathRef);
}

// update the evaltree
set(evalTree, `${entityName}.[${dataPath}]`, data);
// Update context
set(self, `${entityName}.[${dataPath}]`, data);
// Update the datastore
const path = `${entityName}.${dataPath}`;

DataStore.setActionData(path, data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { DataTree } from "entities/DataTree/dataTreeTypes";
import { set } from "lodash";
import DataStore from "../dataStore";
import type { UpdateActionProps } from "./updateActionData";

export function updateActionsToEvalTree(
evalTree: DataTree,
actionsToUpdate?: UpdateActionProps[],
) {
if (!actionsToUpdate) return;

for (const actionToUpdate of actionsToUpdate) {
const { dataPath, dataPathRef, entityName } = actionToUpdate;
let { data } = actionToUpdate;

if (dataPathRef) {
data = DataStore.getActionData(dataPathRef);
DataStore.deleteActionData(dataPathRef);
}

// update the evaltree
set(evalTree, `${entityName}.[${dataPath}]`, data);
// Update context
set(self, `${entityName}.[${dataPath}]`, data);
// Update the datastore
const path = `${entityName}.${dataPath}`;

DataStore.setActionData(path, data);
}
}
2 changes: 1 addition & 1 deletion app/client/src/workers/Evaluation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface EvalTreeRequestData {
widgetsMeta: Record<string, any>;
shouldRespondWithLogs?: boolean;
affectedJSObjects: AffectedJSObjects;
actionDataPayloadConsolidated?: UpdateActionProps;
actionDataPayloadConsolidated?: UpdateActionProps[];
}

export interface EvalTreeResponseData {
Expand Down

0 comments on commit 2b46cd0

Please sign in to comment.