From ebfff4677f053accb5963a400169f88a66262340 Mon Sep 17 00:00:00 2001 From: keyan Date: Sun, 6 Aug 2023 13:13:32 -0500 Subject: [PATCH] fix top header/stat order on back/forward nav --- components/top-header.js | 2 +- components/user-list.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/components/top-header.js b/components/top-header.js index d176a5ec..57af1b1f 100644 --- a/components/top-header.js +++ b/components/top-header.js @@ -32,7 +32,7 @@ export default function TopHeader ({ sub, cat }) { } const what = cat - const by = router.query.by || '' + const by = router.query.by || (what === 'stackers' ? 'stacked' : 'votes') const when = router.query.when || '' return ( diff --git a/components/user-list.js b/components/user-list.js index 23ec9e04..effca4db 100644 --- a/components/user-list.js +++ b/components/user-list.js @@ -42,11 +42,9 @@ export default function UserList ({ ssrData, query, variables, destructureData } const [statComps, setStatComps] = useState(seperate(STAT_COMPONENTS, Seperator)) useEffect(() => { - if (variables?.by) { - // shift the stat we are sorting by to the front - const comps = [...STAT_COMPONENTS] - setStatComps(seperate([...comps.splice(STAT_POS[variables.by], 1), ...comps], Seperator)) - } + // shift the stat we are sorting by to the front + const comps = [...STAT_COMPONENTS] + setStatComps(seperate([...comps.splice(STAT_POS[variables.by || 0], 1), ...comps], Seperator)) }, [variables?.by]) const { users, cursor } = useMemo(() => {