Skip to content

Commit d4defa6

Browse files
committed
refactor: Update async handling in AppStatusModal and service to improve error management and simplify parameters
1 parent 071fff1 commit d4defa6

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/Shared/Components/AppStatusModal/AppStatusModal.component.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const AppStatusModal = ({
6262
fetchedAppDetailsError,
6363
reloadInitialAppDetails,
6464
setFetchedAppDetails,
65-
] = useAsync(getAppDetailsWrapper, [appId, envId], type === 'release')
65+
] = useAsync(getAppDetailsWrapper, [], type === 'release')
6666

6767
const appDetails = type === 'release' ? fetchedAppDetails : appDetailsProp
6868

@@ -82,7 +82,8 @@ const AppStatusModal = ({
8282
envId: appDetails.environmentId,
8383
showTimeline:
8484
selectedTab === AppStatusModalTabType.DEPLOYMENT_STATUS &&
85-
appDetails.deploymentAppType !== DeploymentAppTypes.HELM,
85+
appDetails.deploymentAppType !== DeploymentAppTypes.HELM &&
86+
!appDetails.isVirtualEnvironment,
8687
virtualEnvironmentConfig: appDetails.isVirtualEnvironment
8788
? {
8889
processVirtualEnvironmentDeploymentData,
@@ -105,12 +106,9 @@ const AppStatusModal = ({
105106
deploymentStatusDetailsBreakdownDataError,
106107
reloadDeploymentStatusDetailsBreakdownData,
107108
setDeploymentStatusDetailsBreakdownData,
108-
] = useAsync(
109-
getDeploymentStatusWrapper,
110-
[appId, envId, showDeploymentStatusModal, selectedTab],
111-
!!showDeploymentStatusModal,
112-
{ resetOnChange: false },
113-
)
109+
] = useAsync(getDeploymentStatusWrapper, [showDeploymentStatusModal, selectedTab], !!showDeploymentStatusModal, {
110+
resetOnChange: false,
111+
})
114112

115113
const handleAppDetailsExternalSync = async () => {
116114
appDetailsPollingTimeoutRef.current = setTimeout(
@@ -133,7 +131,12 @@ const AppStatusModal = ({
133131
deploymentStatusDetailsBreakdownData?.deploymentStatus,
134132
)
135133

136-
const pollingIntervalFromFlag = Number(window._env_.DEVTRON_APP_DETAILS_POLLING_INTERVAL) || 30000
134+
const pollingIntervalFromFlag =
135+
Number(
136+
appDetails.appType !== AppType.DEVTRON_HELM_CHART
137+
? window._env_.DEVTRON_APP_DETAILS_POLLING_INTERVAL
138+
: window._env_.HELM_APP_DETAILS_POLLING_INTERVAL,
139+
) || 30000
137140

138141
deploymentStatusPollingTimeoutRef.current = setTimeout(
139142
async () => {

src/Shared/Components/AppStatusModal/service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const getAppDetails = async ({
2121
'env-id': envId,
2222
})
2323

24-
const [appDetails, resourceTree] = await Promise.all([
24+
const [appDetailsResponse, resourceTreeResponse] = await Promise.allSettled([
2525
get<Omit<AppDetails, 'resourceTree'>>(`${ROUTES.APP_DETAIL}/v2${queryParams}`, {
2626
abortControllerRef,
2727
}),
@@ -30,6 +30,13 @@ export const getAppDetails = async ({
3030
}),
3131
])
3232

33+
if (appDetailsResponse.status === 'rejected') {
34+
throw appDetailsResponse.reason
35+
}
36+
37+
const appDetails = appDetailsResponse.value
38+
const resourceTree = resourceTreeResponse.status === 'fulfilled' ? resourceTreeResponse.value : null
39+
3340
return {
3441
...(appDetails.result || ({} as AppDetails)),
3542
resourceTree: resourceTree.result,

0 commit comments

Comments
 (0)