diff --git a/frontend/app/components/shared/SessionsTabOverview/components/LatestSessionsMessage/LatestSessionsMessage.tsx b/frontend/app/components/shared/SessionsTabOverview/components/LatestSessionsMessage/LatestSessionsMessage.tsx index 791ef3d75..66cf7be5a 100644 --- a/frontend/app/components/shared/SessionsTabOverview/components/LatestSessionsMessage/LatestSessionsMessage.tsx +++ b/frontend/app/components/shared/SessionsTabOverview/components/LatestSessionsMessage/LatestSessionsMessage.tsx @@ -23,9 +23,7 @@ function LatestSessionsMessage() { {t('Show')} {numberWithCommas(count)} {t('New')}{' '} {count > 1 ? t('Sessions') : t('Session')} - ) : ( - <> - ); + ) : null; } export default observer(LatestSessionsMessage); diff --git a/frontend/app/components/shared/SessionsTabOverview/components/SessionList/SessionList.tsx b/frontend/app/components/shared/SessionsTabOverview/components/SessionList/SessionList.tsx index 809d6b013..d60d1a3a6 100644 --- a/frontend/app/components/shared/SessionsTabOverview/components/SessionList/SessionList.tsx +++ b/frontend/app/components/shared/SessionsTabOverview/components/SessionList/SessionList.tsx @@ -38,13 +38,10 @@ function SessionList() { } = useStore(); const { isEnterprise } = userStore; const { isLoggedIn } = userStore; - const { list } = sessionStore; - const { lastPlayedSessionId } = sessionStore; + const { lastPlayedSessionId, list, total } = sessionStore; const loading = sessionStore.loadingSessions; - const { total } = sessionStore; const onToggleFavorite = sessionStore.toggleFavorite; - const { siteId } = projectsStore; - const { updateProjectRecordingStatus } = projectsStore; + const { updateProjectRecordingStatus, siteId, previousSiteid } = projectsStore; const { currentPage, activeTab, pageSize } = searchStore; const { filters } = searchStore.instance; const _filterKeys = filters.map((i: any) => i.key); @@ -55,6 +52,11 @@ function SessionList() { const hasNoRecordings = !activeSite || !activeSite.recorded; const metaList = customFieldStore.list; + useEffect(() => { + if (!searchStore.urlParsed || siteId !== previousSiteid) return; + void searchStore.checkForLatestSessionCount(); + }, [location.pathname]); + const NO_CONTENT = React.useMemo(() => { if (isBookmark && !isEnterprise) { return { diff --git a/frontend/app/mstore/projectsStore.ts b/frontend/app/mstore/projectsStore.ts index ce53148d7..0b1caf5c1 100644 --- a/frontend/app/mstore/projectsStore.ts +++ b/frontend/app/mstore/projectsStore.ts @@ -1,4 +1,4 @@ -import { makeAutoObservable, runInAction } from 'mobx'; +import { makeAutoObservable, runInAction, reaction } from 'mobx'; import { GLOBAL_HAS_NO_RECORDINGS, SITE_ID_STORAGE_KEY, @@ -20,6 +20,7 @@ export default class ProjectsStore { instance: Project | null = null; siteId: string | null = null; + previousSiteid: string | null = null; active: Project | null = null; @@ -37,6 +38,15 @@ export default class ProjectsStore { const storedSiteId = localStorage.getItem(SITE_ID_STORAGE_KEY); this.siteId = storedSiteId ?? null; makeAutoObservable(this); + + reaction( + () => this.activeSiteId, + (_, prevId) => { + if (prevId) { + this.previousSiteid = prevId; + } + } + ) } get isMobile() {