ui: fix double fetches for sessions

This commit is contained in:
nick-delirium 2025-03-31 17:14:23 +02:00
parent 6412f14b08
commit f61c5e99b5
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
6 changed files with 8 additions and 20 deletions

View file

@ -125,13 +125,13 @@ function PrivateRoutes() {
}, [siteId]); }, [siteId]);
React.useEffect(() => { React.useEffect(() => {
debounceSearch = debounce(() => searchStore.fetchSessions(), 500); debounceSearch = debounce(() => searchStore.fetchSessions(), 250);
}, []); }, []);
React.useEffect(() => { React.useEffect(() => {
if (!searchStore.urlParsed) return; if (!searchStore.urlParsed) return;
debounceSearch(); debounceSearch();
}, [searchStore.instance.filters, searchStore.instance.eventsOrder]); }, [searchStore.urlParsed, searchStore.instance.filters, searchStore.instance.eventsOrder]);
return ( return (
<Suspense fallback={<Loader loading className="flex-1" />}> <Suspense fallback={<Loader loading className="flex-1" />}>

View file

@ -64,12 +64,6 @@ function LiveSessionList() {
void searchStoreLive.fetchSessions(); void searchStoreLive.fetchSessions();
}; };
useEffect(() => {
if (projectsStore.activeSiteId) {
void searchStoreLive.fetchSessions(true);
}
}, [projectsStore.activeSiteId])
const onUserClick = (userId: string, userAnonymousId: string) => { const onUserClick = (userId: string, userAnonymousId: string) => {
if (userId) { if (userId) {
searchStoreLive.addFilterByKeyAndValue(FilterKey.USERID, userId); searchStoreLive.addFilterByKeyAndValue(FilterKey.USERID, userId);

View file

@ -9,8 +9,10 @@ function LiveSessionSearch() {
const appliedFilter = searchStoreLive.instance; const appliedFilter = searchStoreLive.instance;
useEffect(() => { useEffect(() => {
void searchStoreLive.fetchSessions(); if (projectsStore.activeSiteId) {
}, []); void searchStoreLive.fetchSessions(true);
}
}, [projectsStore.activeSiteId])
const onAddFilter = (filter: any) => { const onAddFilter = (filter: any) => {
filter.autoOpen = true; filter.autoOpen = true;

View file

@ -53,9 +53,6 @@ function SessionFilters() {
onBeforeLoad: async () => { onBeforeLoad: async () => {
await reloadTags(); await reloadTags();
}, },
onLoaded: () => {
debounceFetch = debounce(() => searchStore.fetchSessions(), 500);
}
}); });
const onAddFilter = (filter: any) => { const onAddFilter = (filter: any) => {

View file

@ -49,13 +49,8 @@ const useSessionSearchQueryHandler = ({
searchStore.applyFilter(filter, true); searchStore.applyFilter(filter, true);
} }
// Important: Mark URL as parsed BEFORE fetching
// This prevents the initial fetch when the URL is parsed
searchStore.setUrlParsed(); searchStore.setUrlParsed();
onLoaded?.();
// Then fetch sessions - this is the only place that should fetch initially
await searchStore.fetchSessions();
onLoaded();
} catch (error) { } catch (error) {
console.error('Error applying filter from query:', error); console.error('Error applying filter from query:', error);
searchStore.setUrlParsed(); searchStore.setUrlParsed();

View file

@ -255,7 +255,7 @@ function SideMenu(props: Props) {
<Tag <Tag
color="cyan" color="cyan"
bordered={false} bordered={false}
className="text-xs" className="text-xs ml-2"
> >
{t('Beta')} {t('Beta')}
</Tag> </Tag>