Skip to content

Commit a9d4781

Browse files
MichaelSun48andrewshie-sentry
authored andcommitted
fix(issue-views): Make page filters a parameter in mutate request (#84381)
fixes SENTRY-3MZS (hopefully) This PR updates the useMemo in the debounce function that updates Issue Views to not recreate itself upon page filter changes. Instead, it takes those page filters as parameters. We were seeing cases where the request was being sent in very rapid succession (<200ms apart) despite the debouncing, so one explanation might be that the denounced function is being recreated too frequently, thus "resetting" the timer.
1 parent 4349b77 commit a9d4781

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

static/app/views/issueList/issueViews/issueViews.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilte
1717
import type {TabContext, TabsProps} from 'sentry/components/tabs';
1818
import {tabsShouldForwardProp} from 'sentry/components/tabs/utils';
1919
import {t} from 'sentry/locale';
20+
import type {PageFilters} from 'sentry/types/core';
2021
import type {InjectedRouter} from 'sentry/types/legacyReactRouter';
2122
import {defined} from 'sentry/utils';
2223
import {trackAnalytics} from 'sentry/utils/analytics';
@@ -430,12 +431,12 @@ export function IssueViewsStateProvider({
430431

431432
const debounceUpdateViews = useMemo(
432433
() =>
433-
debounce((newTabs: IssueView[]) => {
434+
debounce((newTabs: IssueView[], pageFiltersSelection: PageFilters) => {
434435
const isAllProjects =
435-
pageFilters.selection.projects.length === 1 &&
436-
pageFilters.selection.projects[0] === -1;
436+
pageFiltersSelection.projects.length === 1 &&
437+
pageFiltersSelection.projects[0] === -1;
437438

438-
const projects = isAllProjects ? [] : pageFilters.selection.projects;
439+
const projects = isAllProjects ? [] : pageFiltersSelection.projects;
439440

440441
if (newTabs) {
441442
updateViews({
@@ -453,19 +454,13 @@ export function IssueViewsStateProvider({
453454
querySort: tab.querySort,
454455
projects,
455456
isAllProjects,
456-
environments: pageFilters.selection.environments,
457-
timeFilters: pageFilters.selection.datetime,
457+
environments: pageFiltersSelection.environments,
458+
timeFilters: pageFiltersSelection.datetime,
458459
})),
459460
});
460461
}
461462
}, 500),
462-
[
463-
organization.slug,
464-
updateViews,
465-
pageFilters.selection.datetime,
466-
pageFilters.selection.environments,
467-
pageFilters.selection.projects,
468-
]
463+
[organization.slug, updateViews]
469464
);
470465

471466
const reducer: Reducer<IssueViewsState, IssueViewsActions> = useCallback(
@@ -536,7 +531,7 @@ export function IssueViewsStateProvider({
536531
dispatch(action);
537532

538533
if (action.type === 'SYNC_VIEWS_TO_BACKEND' || action.syncViews) {
539-
debounceUpdateViews(newState.views);
534+
debounceUpdateViews(newState.views, pageFilters.selection);
540535
}
541536

542537
const actionAnalyticsKey = ACTION_ANALYTICS_MAP[action.type];

0 commit comments

Comments
 (0)