Skip to content

Commit

Permalink
Perf Refactor: Some parent nodes don't load children (#680)
Browse files Browse the repository at this point in the history
fix: checkForDynamicExecutions
  • Loading branch information
james-union authored Feb 10, 2023
1 parent 77fac08 commit ac27601
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/console/src/components/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ export function measureText(fontDefinition: string, text: string) {
*/
export const checkForDynamicExecutions = (allExecutions, staticExecutions) => {
const parentsToFetch = {};
const executionsByNodeId = {};
for (const executionId in allExecutions) {
const execution = allExecutions[executionId];
executionsByNodeId[execution.id.nodeId] = execution;
if (!staticExecutions[executionId]) {
const dynamicExecution = allExecutions[executionId];
if (dynamicExecution) {
if (execution) {
const dynamicExecutionId =
dynamicExecution.metadata?.specNodeId || dynamicExecution.id;
const uniqueParentId = dynamicExecution.fromUniqueParentId;
execution.metadata?.specNodeId || execution.id;
const uniqueParentId = execution.fromUniqueParentId;
if (uniqueParentId) {
if (parentsToFetch[uniqueParentId]) {
parentsToFetch[uniqueParentId].push(dynamicExecutionId);
Expand All @@ -46,7 +48,8 @@ export const checkForDynamicExecutions = (allExecutions, staticExecutions) => {
}
const result = {};
for (const parentId in parentsToFetch) {
result[parentId] = allExecutions[parentId];
const execution = executionsByNodeId[parentId];
result[execution.scopedId] = execution;
}
return result;
};

0 comments on commit ac27601

Please sign in to comment.