From 048ae0913cd7556202a0b39ecfe39695e8d328cf Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Wed, 19 Mar 2025 17:36:28 +0100 Subject: [PATCH] ui: refetch live session list on proj change --- .../components/shared/LiveSessionList/LiveSessionList.tsx | 8 +++++++- frontend/app/mstore/searchStoreLive.ts | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx b/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx index 6445d6847..94f97293c 100644 --- a/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx +++ b/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx @@ -19,7 +19,7 @@ const AUTOREFRESH_INTERVAL = 2 * 60 * 1000; const PER_PAGE = 10; function LiveSessionList() { - const { searchStoreLive, sessionStore, customFieldStore } = useStore(); + const { searchStoreLive, sessionStore, customFieldStore, projectsStore } = useStore(); const filter = searchStoreLive.instance; const list = sessionStore.liveSessions; const { totalLiveSessions } = sessionStore; @@ -72,6 +72,12 @@ function LiveSessionList() { void searchStoreLive.fetchSessions(); }; + useEffect(() => { + if (projectsStore.activeSiteId) { + void searchStoreLive.fetchSessions(true); + } + }, [projectsStore.activeSiteId]) + const onUserClick = (userId: string, userAnonymousId: string) => { if (userId) { searchStoreLive.addFilterByKeyAndValue(FilterKey.USERID, userId); diff --git a/frontend/app/mstore/searchStoreLive.ts b/frontend/app/mstore/searchStoreLive.ts index 526403310..0238fb559 100644 --- a/frontend/app/mstore/searchStoreLive.ts +++ b/frontend/app/mstore/searchStoreLive.ts @@ -248,7 +248,10 @@ class SearchStoreLive { this.loading = val; } - fetchSessions = async () => { + fetchSessions = async (force?: boolean) => { + if (!force && this.loading) { + return; + } this.setLoading(true) try { await sessionStore.fetchLiveSessions({