From 7fd741348ce50d99856405198cd45b294658510b Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Wed, 16 Apr 2025 11:55:47 +0200 Subject: [PATCH] ui: fix session search on url change --- frontend/app/PrivateRoutes.tsx | 11 ++--------- frontend/app/mstore/searchStore.ts | 5 +++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/frontend/app/PrivateRoutes.tsx b/frontend/app/PrivateRoutes.tsx index 9169d9344..933627087 100644 --- a/frontend/app/PrivateRoutes.tsx +++ b/frontend/app/PrivateRoutes.tsx @@ -1,5 +1,4 @@ import withSiteIdUpdater from 'HOCs/withSiteIdUpdater'; -import withSiteIdUpdater from 'HOCs/withSiteIdUpdater'; import React, { Suspense, lazy } from 'react'; import { Redirect, Route, Switch } from 'react-router-dom'; import { observer } from 'mobx-react-lite'; @@ -10,7 +9,7 @@ import { Loader } from 'UI'; import APIClient from './api_client'; import * as routes from './routes'; -import { debounce } from '@/utils'; +import { debounceCall } from '@/utils'; const components: any = { SessionPure: lazy(() => import('Components/Session/Session')), @@ -88,7 +87,6 @@ const ASSIST_PATH = routes.assist(); const LIVE_SESSION_PATH = routes.liveSession(); const MULTIVIEW_PATH = routes.multiview(); const MULTIVIEW_INDEX_PATH = routes.multiviewIndex(); -const ASSIST_STATS_PATH = routes.assistStats(); const USABILITY_TESTING_PATH = routes.usabilityTesting(); const USABILITY_TESTING_EDIT_PATH = routes.usabilityTestingEdit(); @@ -99,7 +97,6 @@ const SPOT_PATH = routes.spot(); const SCOPE_SETUP = routes.scopeSetup(); const HIGHLIGHTS_PATH = routes.highlights(); -let debounceSearch: any = () => {}; function PrivateRoutes() { const { projectsStore, userStore, integrationsStore, searchStore } = useStore(); @@ -124,13 +121,9 @@ function PrivateRoutes() { } }, [siteId]); - React.useEffect(() => { - debounceSearch = debounce(() => searchStore.fetchSessions(), 250); - }, []); - React.useEffect(() => { if (!searchStore.urlParsed) return; - debounceSearch(); + debounceCall(() => searchStore.fetchSessions(true), 250)() }, [searchStore.urlParsed, searchStore.instance.filters, searchStore.instance.eventsOrder]); return ( diff --git a/frontend/app/mstore/searchStore.ts b/frontend/app/mstore/searchStore.ts index 1f2e74553..933335e57 100644 --- a/frontend/app/mstore/searchStore.ts +++ b/frontend/app/mstore/searchStore.ts @@ -394,10 +394,11 @@ class SearchStore { // TODO } - async fetchSessions( + fetchSessions = async ( force: boolean = false, bookmarked: boolean = false, - ): Promise { + ): Promise => { + console.log(this.searchInProgress) if (this.searchInProgress) return; const filter = this.instance.toSearch();