@@ -36,7 +36,7 @@ import { MessageBarType } from '@fluentui/react';
36
36
import { RunService , equals , isNullOrUndefined , removeIdTag , useNodeIndex } from '@microsoft/logic-apps-shared' ;
37
37
import { ScopeCard } from '@microsoft/designer-ui' ;
38
38
import type { LogicAppsV2 } from '@microsoft/logic-apps-shared' ;
39
- import { memo , useCallback , useMemo , useRef , useState } from 'react' ;
39
+ import { memo , useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
40
40
import { useDrag } from 'react-dnd' ;
41
41
import { useIntl } from 'react-intl' ;
42
42
import { useQuery } from '@tanstack/react-query' ;
@@ -72,31 +72,24 @@ const ScopeCardNode = ({ data, targetPosition = Position.Top, sourcePosition = P
72
72
) ;
73
73
const rootRef = useRef < HTMLDivElement | null > ( null ) ;
74
74
75
- const getRunRepetition = useCallback ( ( ) => {
76
- if ( parentRunData ?. status === constants . FLOW_STATUS . SKIPPED ) {
77
- return {
78
- properties : {
79
- status : constants . FLOW_STATUS . SKIPPED ,
80
- inputsLink : null ,
81
- outputsLink : null ,
82
- startTime : null ,
83
- endTime : null ,
84
- trackingId : null ,
85
- correlation : null ,
86
- } ,
87
- } ;
88
- }
89
- return RunService ( ) . getRepetition ( { nodeId : scopeId , runId : runInstance ?. id } , repetitionName ) ;
90
- } , [ scopeId , parentRunData ?. status , repetitionName , runInstance ?. id ] ) ;
91
-
92
- const { isLoading : isRepetitionLoading , isRefetching : isRepetitionRefetching } = useQuery < any > (
75
+ const { isFetching : isRepetitionFetching , data : repetitionRunData } = useQuery < any > (
93
76
[ 'runInstance' , { nodeId : scopeId , runId : runInstance ?. id , repetitionName, parentStatus : parentRunData ?. status } ] ,
94
77
async ( ) => {
95
- const data = await getRunRepetition ( ) ;
96
- if ( ! isNullOrUndefined ( data ) ) {
97
- dispatch ( setRepetitionRunData ( { nodeId : scopeId , runData : data . properties as LogicAppsV2 . WorkflowRunAction } ) ) ;
78
+ if ( parentRunData ?. status === constants . FLOW_STATUS . SKIPPED ) {
79
+ return {
80
+ properties : {
81
+ status : constants . FLOW_STATUS . SKIPPED ,
82
+ inputsLink : null ,
83
+ outputsLink : null ,
84
+ startTime : null ,
85
+ endTime : null ,
86
+ trackingId : null ,
87
+ correlation : null ,
88
+ } ,
89
+ } ;
98
90
}
99
- return data ;
91
+
92
+ return await RunService ( ) . getRepetition ( { nodeId : scopeId , runId : runInstance ?. id } , repetitionName ) ;
100
93
} ,
101
94
{
102
95
refetchOnWindowFocus : false ,
@@ -107,6 +100,12 @@ const ScopeCardNode = ({ data, targetPosition = Position.Top, sourcePosition = P
107
100
}
108
101
) ;
109
102
103
+ useEffect ( ( ) => {
104
+ if ( ! isNullOrUndefined ( repetitionRunData ) ) {
105
+ dispatch ( setRepetitionRunData ( { nodeId : scopeId , runData : repetitionRunData . properties as LogicAppsV2 . WorkflowRunAction } ) ) ;
106
+ }
107
+ } , [ dispatch , repetitionRunData , scopeId ] ) ;
108
+
110
109
const { dependencies, loopSources } = useTokenDependencies ( scopeId ) ;
111
110
const [ { isDragging } , drag , dragPreview ] = useDrag (
112
111
( ) => ( {
@@ -196,8 +195,8 @@ const ScopeCardNode = ({ data, targetPosition = Position.Top, sourcePosition = P
196
195
const opQuery = useOperationQuery ( scopeId ) ;
197
196
198
197
const isLoading = useMemo (
199
- ( ) => isRepetitionLoading || isRepetitionRefetching || opQuery . isLoading || ( ! brandColor && ! iconUri ) ,
200
- [ brandColor , iconUri , opQuery . isLoading , isRepetitionLoading , isRepetitionRefetching ]
198
+ ( ) => isRepetitionFetching || opQuery . isLoading || ( ! brandColor && ! iconUri ) ,
199
+ [ brandColor , iconUri , opQuery . isLoading , isRepetitionFetching ]
201
200
) ;
202
201
203
202
const comment = useMemo (
@@ -265,7 +264,6 @@ const ScopeCardNode = ({ data, targetPosition = Position.Top, sourcePosition = P
265
264
if ( metadata ?. runData ?. status && ! equals ( metadata . runData . status , 'InProgress' ) ) {
266
265
return < LoopsPager metadata = { metadata } scopeId = { scopeId } collapsed = { graphCollapsed } /> ;
267
266
}
268
-
269
267
return null ;
270
268
} , [ graphCollapsed , metadata , scopeId ] ) ;
271
269
0 commit comments