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]);
React.useEffect(() => {
debounceSearch = debounce(() => searchStore.fetchSessions(), 500);
debounceSearch = debounce(() => searchStore.fetchSessions(), 250);
}, []);
React.useEffect(() => {
if (!searchStore.urlParsed) return;
debounceSearch();
}, [searchStore.instance.filters, searchStore.instance.eventsOrder]);
}, [searchStore.urlParsed, searchStore.instance.filters, searchStore.instance.eventsOrder]);
return (
<Suspense fallback={<Loader loading className="flex-1" />}>

View file

@ -64,12 +64,6 @@ 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);

View file

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

View file

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

View file

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

View file

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