From c48913d91e7e775043c3d58b30973bbc1fb1d2a9 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 17 Feb 2022 18:18:40 -0600 Subject: [PATCH] Sort bets/comments on client. Somehow server order is getting flipped? --- web/hooks/use-bets.ts | 4 +--- web/pages/[username]/[contractSlug].tsx | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/hooks/use-bets.ts b/web/hooks/use-bets.ts index 0b6b9293..03a0cb49 100644 --- a/web/hooks/use-bets.ts +++ b/web/hooks/use-bets.ts @@ -14,9 +14,7 @@ export const useBets = (contractId: string) => { export const useBetsWithoutAntes = (contract: Contract, initialBets: Bet[]) => { const [bets, setBets] = useState( - withoutAnteBets(contract, initialBets).sort( - (bet1, bet2) => bet1.createdTime - bet2.createdTime - ) + withoutAnteBets(contract, initialBets) ) useEffect(() => { diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 98c314a4..08cbb337 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -82,6 +82,10 @@ export default function ContractPage(props: { const contract = useContractWithPreload(props.slug, props.contract) const { bets, comments } = props + // Sort for now to see if bug is fixed. + comments.sort((c1, c2) => c1.createdTime - c2.createdTime) + bets.sort((bet1, bet2) => bet1.createdTime - bet2.createdTime) + const folds = (useFoldsWithTags(contract?.tags) ?? props.folds).filter( (fold) => fold.followCount > 1 || user?.id === fold.curatorId )