diff --git a/static/app/components/replays/table/useReplayTableSort.tsx b/static/app/components/replays/table/useReplayTableSort.tsx index 438e2101797d2b..511f20f9e9c988 100644 --- a/static/app/components/replays/table/useReplayTableSort.tsx +++ b/static/app/components/replays/table/useReplayTableSort.tsx @@ -12,10 +12,11 @@ interface Props { queryParamKey?: string; } -const DEFAULT_SORT = {field: 'started_at', kind: 'desc'} as const; +const DECODED_DEFAULT_REPLAY_LIST_SORT: Sort = {field: 'started_at', kind: 'desc'}; +export const DEFAULT_REPLAY_LIST_SORT = encodeSort(DECODED_DEFAULT_REPLAY_LIST_SORT); export default function useReplayTableSort({ - defaultSort = DEFAULT_SORT, + defaultSort = DECODED_DEFAULT_REPLAY_LIST_SORT, queryParamKey = 'sort', }: Props = {}) { const organization = useOrganization(); diff --git a/static/app/utils/replays/fetchReplayList.tsx b/static/app/utils/replays/fetchReplayList.tsx index 1adde8fc346219..904e087352fc52 100644 --- a/static/app/utils/replays/fetchReplayList.tsx +++ b/static/app/utils/replays/fetchReplayList.tsx @@ -10,8 +10,6 @@ import {mapResponseToReplayRecord} from 'sentry/utils/replays/replayDataUtils'; import type RequestError from 'sentry/utils/requestError/requestError'; import type {ReplayListQueryReferrer, ReplayListRecord} from 'sentry/views/replays/types'; -export const DEFAULT_SORT = '-started_at'; - type State = { fetchError: undefined | RequestError; pageLinks: null | string; diff --git a/static/app/utils/replays/hooks/useReplayList.tsx b/static/app/utils/replays/hooks/useReplayList.tsx index cc58a33c6392ae..c69c40428ae741 100644 --- a/static/app/utils/replays/hooks/useReplayList.tsx +++ b/static/app/utils/replays/hooks/useReplayList.tsx @@ -24,6 +24,10 @@ type State = Awaited> & {isFetching: boolean} type Result = State; +/** + * @deprecated due to its reliance on EventView which is unpleasant to work with + * Use useApiQuery instead + */ function useReplayList({ enabled = true, eventView, diff --git a/static/app/views/issueDetails/groupReplays/useReplaysFromIssue.tsx b/static/app/views/issueDetails/groupReplays/useReplaysFromIssue.tsx index d6685445d94bff..9f11f509d3ba9f 100644 --- a/static/app/views/issueDetails/groupReplays/useReplaysFromIssue.tsx +++ b/static/app/views/issueDetails/groupReplays/useReplaysFromIssue.tsx @@ -2,12 +2,12 @@ import {useCallback, useEffect, useMemo, useState} from 'react'; import * as Sentry from '@sentry/react'; import type {Location} from 'history'; +import {DEFAULT_REPLAY_LIST_SORT} from 'sentry/components/replays/table/useReplayTableSort'; import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters'; import {IssueCategory, type Group} from 'sentry/types/group'; import type {Organization} from 'sentry/types/organization'; import EventView from 'sentry/utils/discover/eventView'; import {decodeScalar} from 'sentry/utils/queryString'; -import {DEFAULT_SORT} from 'sentry/utils/replays/fetchReplayList'; import type RequestError from 'sentry/utils/requestError/requestError'; import useApi from 'sentry/utils/useApi'; import useCleanQueryParamsOnRouteLeave from 'sentry/utils/useCleanQueryParamsOnRouteLeave'; @@ -66,7 +66,7 @@ export default function useReplaysFromIssue({ query: replayIds.length ? `id:[${String(replayIds)}]` : `id:1`, range: '90d', projects: [], - orderby: decodeScalar(location.query.sort, DEFAULT_SORT), + orderby: decodeScalar(location.query.sort, DEFAULT_REPLAY_LIST_SORT), }); }, [location.query.sort, replayIds]); diff --git a/static/app/views/performance/transactionSummary/transactionReplays/useReplaysFromTransaction.tsx b/static/app/views/performance/transactionSummary/transactionReplays/useReplaysFromTransaction.tsx index 2afb57413723a4..0e21d5e6a40a0b 100644 --- a/static/app/views/performance/transactionSummary/transactionReplays/useReplaysFromTransaction.tsx +++ b/static/app/views/performance/transactionSummary/transactionReplays/useReplaysFromTransaction.tsx @@ -2,11 +2,11 @@ import {useCallback, useEffect, useMemo, useState} from 'react'; import * as Sentry from '@sentry/react'; import type {Location} from 'history'; +import {DEFAULT_REPLAY_LIST_SORT} from 'sentry/components/replays/table/useReplayTableSort'; import type {Organization} from 'sentry/types/organization'; import EventView from 'sentry/utils/discover/eventView'; import {doDiscoverQuery} from 'sentry/utils/discover/genericDiscoverQuery'; import {decodeScalar} from 'sentry/utils/queryString'; -import {DEFAULT_SORT} from 'sentry/utils/replays/fetchReplayList'; import useApi from 'sentry/utils/useApi'; import type {ReplayListLocationQuery} from 'sentry/views/replays/types'; import {REPLAY_LIST_FIELDS} from 'sentry/views/replays/types'; @@ -90,7 +90,7 @@ function useReplaysFromTransaction({ fields: REPLAY_LIST_FIELDS, projects: [], query: response.replayIds.length ? `id:[${String(response.replayIds)}]` : undefined, - orderby: decodeScalar(location.query.sort, DEFAULT_SORT), + orderby: decodeScalar(location.query.sort, DEFAULT_REPLAY_LIST_SORT), }); }, [location.query.sort, response.replayIds]);