Skip to content

Commit 88ce0c3

Browse files
Merge pull request #2737 from devtron-labs/fix/clear-app-refetch-timer
fix: clear timeout for app details in case refetchData query is present
2 parents 159b28c + ddfed5d commit 88ce0c3

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

src/components/externalArgoApps/ExternalArgoAppDetail.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
5959
}, [])
6060

6161
useEffect(() => {
62+
let timer: ReturnType<typeof setTimeout>
63+
6264
if (checkIfToRefetchData(location)) {
63-
setTimeout(() => {
65+
timer = setTimeout(() => {
6466
_getAndSetAppDetail()
6567
deleteRefetchDataFromUrl(history, location)
6668
}, 2000)
6769
}
70+
71+
return () => {
72+
if (timer) {
73+
clearTimeout(timer)
74+
}
75+
}
6876
}, [location.search])
6977

7078
const _init = () => {

src/components/v2/appDetails/ea/EAAppDetail.component.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,20 @@ const ExternalAppDetail = ({ appId, appName, isExternalApp }) => {
7171
}, [])
7272

7373
useEffect(() => {
74+
let timer: ReturnType<typeof setTimeout>
75+
7476
if (checkIfToRefetchData(location)) {
75-
setTimeout(() => {
77+
timer = setTimeout(() => {
7678
_getAndSetAppDetail()
7779
deleteRefetchDataFromUrl(history, location)
7880
}, 2000)
7981
}
82+
83+
return () => {
84+
if (timer) {
85+
clearTimeout(timer)
86+
}
87+
}
8088
}, [location.search])
8189

8290
const _init = () => {

src/components/v2/chartDeploymentHistory/ChartDeploymentHistory.component.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,14 @@ const ChartDeploymentHistory = ({
337337
gridColumnGap: '12px',
338338
}}
339339
>
340-
<AppStatus
341-
status={getDeploymentStatus(deployment)}
342-
hideMessage
343-
iconSize={24}
344-
hideIconTooltip
345-
/>
340+
<div className="flex icon-dim-24 dc__no-shrink">
341+
<AppStatus
342+
status={getDeploymentStatus(deployment)}
343+
hideMessage
344+
iconSize={24}
345+
hideIconTooltip
346+
/>
347+
</div>
346348
<div className="flex column left dc__ellipsis-right">
347349
<div className="cn-9 fs-14" data-testid="chart-deployment-time">
348350
{moment(new Date(deployment.deployedAt.seconds * 1000)).format(

src/components/v2/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,20 @@ const RouterComponent = () => {
101101
)
102102

103103
useEffect(() => {
104+
let timer: ReturnType<typeof setTimeout>
105+
104106
if (checkIfToRefetchData(location)) {
105-
setTimeout(() => {
107+
timer = setTimeout(() => {
106108
abortPreviousRequests(() => _getAndSetAppDetail(true), abortControllerRef)
107109
deleteRefetchDataFromUrl(history, location)
108110
}, 5000)
109111
}
112+
113+
return () => {
114+
if (timer) {
115+
clearTimeout(timer)
116+
}
117+
}
110118
}, [location.search])
111119

112120
const _init = (fetchExternalLinks?: boolean) => {

0 commit comments

Comments
 (0)