diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 0ba90c54..c2773741 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -45,6 +45,11 @@ import { UserLink } from 'web/components/user-link' import { useUserBetContracts } from 'web/hooks/use-contracts' import { BetsSummary } from './bet-summary' import { ProfitBadge } from './profit-badge' +import { + storageStore, + usePersistentState, +} from 'web/hooks/use-persistent-state' +import { safeLocalStorage } from 'web/lib/util/local' type BetSort = 'newest' | 'profit' | 'closeTime' | 'value' type BetFilter = 'open' | 'limit_bet' | 'sold' | 'closed' | 'resolved' | 'all' @@ -75,8 +80,14 @@ export function BetsList(props: { user: User }) { return contractList ? keyBy(contractList, 'id') : undefined }, [contractList]) - const [sort, setSort] = useState('newest') - const [filter, setFilter] = useState('all') + const [sort, setSort] = usePersistentState('newest', { + key: 'bets-list-sort', + store: storageStore(safeLocalStorage()), + }) + const [filter, setFilter] = usePersistentState('all', { + key: 'bets-list-filter', + store: storageStore(safeLocalStorage()), + }) const [page, setPage] = useState(0) const start = page * CONTRACTS_PER_PAGE const end = start + CONTRACTS_PER_PAGE