Skip to content

Commit 8d4efb6

Browse files
jerryzhou196andrewshie-sentry
authored andcommitted
ref(replays): Rename and export default sort constant for replay list; update usages across components (#103248)
- Changed `DEFAULT_SORT` to `DEFAULT_REPLAY_LIST_SORT` for clarity and consistency. - Updated `useReplayTableSort` to use the new constant. - Removed unused `DEFAULT_SORT` from `fetchReplayList`. - Updated sorting logic in `useReplaysFromIssue` and `useReplaysFromTransaction` to utilize the new constant. - Marked `useReplayList` as deprecated in favor of `useApiQuery`.
1 parent 72c850b commit 8d4efb6

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

static/app/components/replays/table/useReplayTableSort.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ interface Props {
1212
queryParamKey?: string;
1313
}
1414

15-
const DEFAULT_SORT = {field: 'started_at', kind: 'desc'} as const;
15+
const DECODED_DEFAULT_REPLAY_LIST_SORT: Sort = {field: 'started_at', kind: 'desc'};
16+
export const DEFAULT_REPLAY_LIST_SORT = encodeSort(DECODED_DEFAULT_REPLAY_LIST_SORT);
1617

1718
export default function useReplayTableSort({
18-
defaultSort = DEFAULT_SORT,
19+
defaultSort = DECODED_DEFAULT_REPLAY_LIST_SORT,
1920
queryParamKey = 'sort',
2021
}: Props = {}) {
2122
const organization = useOrganization();

static/app/utils/replays/fetchReplayList.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {mapResponseToReplayRecord} from 'sentry/utils/replays/replayDataUtils';
1010
import type RequestError from 'sentry/utils/requestError/requestError';
1111
import type {ReplayListQueryReferrer, ReplayListRecord} from 'sentry/views/replays/types';
1212

13-
export const DEFAULT_SORT = '-started_at';
14-
1513
type State = {
1614
fetchError: undefined | RequestError;
1715
pageLinks: null | string;

static/app/utils/replays/hooks/useReplayList.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type State = Awaited<ReturnType<typeof fetchReplayList>> & {isFetching: boolean}
2424

2525
type Result = State;
2626

27+
/**
28+
* @deprecated due to its reliance on EventView which is unpleasant to work with
29+
* Use useApiQuery instead
30+
*/
2731
function useReplayList({
2832
enabled = true,
2933
eventView,

static/app/views/issueDetails/groupReplays/useReplaysFromIssue.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import {useCallback, useEffect, useMemo, useState} from 'react';
22
import * as Sentry from '@sentry/react';
33
import type {Location} from 'history';
44

5+
import {DEFAULT_REPLAY_LIST_SORT} from 'sentry/components/replays/table/useReplayTableSort';
56
import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
67
import {IssueCategory, type Group} from 'sentry/types/group';
78
import type {Organization} from 'sentry/types/organization';
89
import EventView from 'sentry/utils/discover/eventView';
910
import {decodeScalar} from 'sentry/utils/queryString';
10-
import {DEFAULT_SORT} from 'sentry/utils/replays/fetchReplayList';
1111
import type RequestError from 'sentry/utils/requestError/requestError';
1212
import useApi from 'sentry/utils/useApi';
1313
import useCleanQueryParamsOnRouteLeave from 'sentry/utils/useCleanQueryParamsOnRouteLeave';
@@ -66,7 +66,7 @@ export default function useReplaysFromIssue({
6666
query: replayIds.length ? `id:[${String(replayIds)}]` : `id:1`,
6767
range: '90d',
6868
projects: [],
69-
orderby: decodeScalar(location.query.sort, DEFAULT_SORT),
69+
orderby: decodeScalar(location.query.sort, DEFAULT_REPLAY_LIST_SORT),
7070
});
7171
}, [location.query.sort, replayIds]);
7272

static/app/views/performance/transactionSummary/transactionReplays/useReplaysFromTransaction.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import {useCallback, useEffect, useMemo, useState} from 'react';
22
import * as Sentry from '@sentry/react';
33
import type {Location} from 'history';
44

5+
import {DEFAULT_REPLAY_LIST_SORT} from 'sentry/components/replays/table/useReplayTableSort';
56
import type {Organization} from 'sentry/types/organization';
67
import EventView from 'sentry/utils/discover/eventView';
78
import {doDiscoverQuery} from 'sentry/utils/discover/genericDiscoverQuery';
89
import {decodeScalar} from 'sentry/utils/queryString';
9-
import {DEFAULT_SORT} from 'sentry/utils/replays/fetchReplayList';
1010
import useApi from 'sentry/utils/useApi';
1111
import type {ReplayListLocationQuery} from 'sentry/views/replays/types';
1212
import {REPLAY_LIST_FIELDS} from 'sentry/views/replays/types';
@@ -90,7 +90,7 @@ function useReplaysFromTransaction({
9090
fields: REPLAY_LIST_FIELDS,
9191
projects: [],
9292
query: response.replayIds.length ? `id:[${String(response.replayIds)}]` : undefined,
93-
orderby: decodeScalar(location.query.sort, DEFAULT_SORT),
93+
orderby: decodeScalar(location.query.sort, DEFAULT_REPLAY_LIST_SORT),
9494
});
9595
}, [location.query.sort, response.replayIds]);
9696

0 commit comments

Comments
 (0)