fix: Js object - set async tag after all objects are parsed (#12684)
* set isAsync after all parsing is done * clean up
This commit is contained in:
parent
19d0db30b0
commit
8420f6c5fa
|
|
@ -9,6 +9,8 @@ export type ParsedJSSubAction = {
|
|||
body: string;
|
||||
arguments: Array<Variable>;
|
||||
isAsync: boolean;
|
||||
// parsedFunction - used only to determine if function is async
|
||||
parsedFunction?: () => unknown;
|
||||
};
|
||||
|
||||
export type ParsedBody = {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ import { Severity } from "entities/AppsmithConsole";
|
|||
import { getLintingErrors } from "workers/lint";
|
||||
import { error as logError } from "loglevel";
|
||||
import { extractIdentifiersFromCode } from "workers/ast";
|
||||
import { JSUpdate } from "utils/JSPaneUtils";
|
||||
import { JSUpdate, ParsedJSSubAction } from "utils/JSPaneUtils";
|
||||
import {
|
||||
addWidgetPropertyDependencies,
|
||||
overrideWidgetProperties,
|
||||
|
|
@ -1021,7 +1021,7 @@ export default class DataTreeEvaluator {
|
|||
|
||||
saveResolvedFunctionsAndJSUpdates(
|
||||
entity: DataTreeJSAction,
|
||||
jsUpdates: Record<string, any>,
|
||||
jsUpdates: Record<string, JSUpdate>,
|
||||
unEvalDataTree: DataTree,
|
||||
entityName: string,
|
||||
) {
|
||||
|
|
@ -1034,7 +1034,7 @@ export default class DataTreeEvaluator {
|
|||
delete this.resolvedFunctions[`${entityName}`];
|
||||
delete this.currentJSCollectionState[`${entityName}`];
|
||||
if (result) {
|
||||
const actions: any = [];
|
||||
const actions: ParsedJSSubAction[] = [];
|
||||
const variables: any = [];
|
||||
Object.keys(result).forEach((unEvalFunc) => {
|
||||
const unEvalValue = result[unEvalFunc];
|
||||
|
|
@ -1055,7 +1055,8 @@ export default class DataTreeEvaluator {
|
|||
name: unEvalFunc,
|
||||
body: functionString,
|
||||
arguments: params,
|
||||
value: unEvalValue,
|
||||
parsedFunction: unEvalValue,
|
||||
isAsync: false,
|
||||
});
|
||||
} else {
|
||||
variables.push({
|
||||
|
|
@ -1070,23 +1071,9 @@ export default class DataTreeEvaluator {
|
|||
}
|
||||
});
|
||||
|
||||
const modifiedActions = actions.map((action: any) => {
|
||||
return {
|
||||
name: action.name,
|
||||
body: action.body,
|
||||
arguments: action.arguments,
|
||||
isAsync: isFunctionAsync(
|
||||
action.value,
|
||||
unEvalDataTree,
|
||||
this.resolvedFunctions,
|
||||
this.logs,
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
const parsedBody = {
|
||||
body: entity.body,
|
||||
actions: modifiedActions,
|
||||
actions: actions,
|
||||
variables,
|
||||
};
|
||||
_.set(jsUpdates, `${entityName}`, {
|
||||
|
|
@ -1129,7 +1116,7 @@ export default class DataTreeEvaluator {
|
|||
differences?: DataTreeDiff[],
|
||||
oldUnEvalTree?: DataTree,
|
||||
) {
|
||||
let jsUpdates = {};
|
||||
let jsUpdates: Record<string, JSUpdate> = {};
|
||||
if (!!differences && !!oldUnEvalTree) {
|
||||
differences.forEach((diff) => {
|
||||
const { entityName, propertyPath } = getEntityNameAndPropertyPath(
|
||||
|
|
@ -1183,6 +1170,23 @@ export default class DataTreeEvaluator {
|
|||
);
|
||||
});
|
||||
}
|
||||
Object.keys(jsUpdates).forEach((entityName) => {
|
||||
const parsedBody = jsUpdates[entityName].parsedBody;
|
||||
if (!parsedBody) return;
|
||||
parsedBody.actions = parsedBody.actions.map((action) => {
|
||||
return {
|
||||
...action,
|
||||
isAsync: isFunctionAsync(
|
||||
action.parsedFunction,
|
||||
unEvalDataTree,
|
||||
this.resolvedFunctions,
|
||||
this.logs,
|
||||
),
|
||||
// parsedFunction - used only to determine if function is async
|
||||
parsedFunction: undefined,
|
||||
} as ParsedJSSubAction;
|
||||
});
|
||||
});
|
||||
return { jsUpdates };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user