Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions static/app/components/replays/table/useReplayTableSort.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useCallback, useRef} from 'react';
import {useCallback} from 'react';

import {trackAnalytics} from 'sentry/utils/analytics';
import {encodeSort} from 'sentry/utils/discover/eventView';
Expand All @@ -12,18 +12,17 @@ interface Props {
queryParamKey?: string;
}

const DEFAULT_SORT = {field: 'started_at', kind: 'asc'} as const;
const DEFAULT_SORT = {field: 'started_at', kind: 'desc'} as const;

export default function useReplayTableSort({
defaultSort = DEFAULT_SORT,
queryParamKey = 'sort',
}: Props = {}) {
const defaultSortRef = useRef(defaultSort);
const organization = useOrganization();

const {getParamValue, setParamValue} = useUrlParams(queryParamKey, '-started_at');
const {getParamValue, setParamValue} = useUrlParams(queryParamKey, '');
const sortQuery = getParamValue();
const sortType = decodeSorts(sortQuery).at(0) ?? defaultSortRef.current;
const sortType = decodeSorts(sortQuery).at(0) ?? defaultSort;

const handleSortClick = useCallback(
(key: string) => {
Expand Down
Loading