From 53b71d70627558eca228226483178387f4de8b51 Mon Sep 17 00:00:00 2001 From: Abhi kumar Date: Tue, 15 Jul 2025 15:17:14 +0530 Subject: [PATCH] fix: revalidate changelog on tab visibility change (#8532) * fix: added changes for revalidation changelog on tab change * chore: removed four hours diff change --- frontend/src/container/AppLayout/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/container/AppLayout/index.tsx b/frontend/src/container/AppLayout/index.tsx index c84297b3bac2..fdcfbaa5772f 100644 --- a/frontend/src/container/AppLayout/index.tsx +++ b/frontend/src/container/AppLayout/index.tsx @@ -27,6 +27,7 @@ import dayjs from 'dayjs'; import { useIsDarkMode } from 'hooks/useDarkMode'; import { useGetTenantLicense } from 'hooks/useGetTenantLicense'; import { useNotifications } from 'hooks/useNotifications'; +import useTabVisibility from 'hooks/useTabFocus'; import history from 'lib/history'; import { isNull } from 'lodash-es'; import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback'; @@ -154,6 +155,8 @@ function AppLayout(props: AppLayoutProps): JSX.Element { preference.name === USER_PREFERENCES.LAST_SEEN_CHANGELOG_VERSION, )?.value as string; + const isVisible = useTabVisibility(); + const [ getUserVersionResponse, getUserLatestVersionResponse, @@ -177,6 +180,13 @@ function AppLayout(props: AppLayoutProps): JSX.Element { }, ]); + useEffect(() => { + // refetch the changelog only when the current tab becomes active + there isn't an active request + no changelog already available + if (!changelog && !getChangelogByVersionResponse.isLoading && isVisible) { + getChangelogByVersionResponse.refetch(); + } + }, [isVisible, changelog, getChangelogByVersionResponse]); + useEffect(() => { let timer: ReturnType; if (