Skip to content

Commit 5354c3c

Browse files
fix: leaderboard page
1 parent 93cac5e commit 5354c3c

1 file changed

Lines changed: 38 additions & 40 deletions

File tree

src/pages/leaderboard.tsx

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,47 +43,45 @@ const Leaderboard: React.FC = () => {
4343
return `${diffInDays} day${diffInDays > 1 ? 's' : ''} ago`
4444
}
4545

46-
const fetchLeaderboard = useCallback(async () => {
47-
setLoading(true)
48-
const lb = await fetchLeaderboard()
49-
setLastUpdated(new Date(lb.last_updated + 'Z'))
50-
setLeaderboard([
51-
{
52-
id: 'regular',
53-
icon: <RegularPlayIcon />,
54-
name: 'Regular',
55-
ranking: lb.play_leaders,
56-
},
57-
{
58-
id: 'puzzles',
59-
icon: <TrainIcon />,
60-
name: 'Puzzles',
61-
ranking: lb.puzzles_leaders,
62-
},
63-
{
64-
id: 'turing',
65-
icon: <BotOrNotIcon />,
66-
name: 'Bot/Not',
67-
ranking: lb.turing_leaders,
68-
},
69-
{
70-
id: 'hand',
71-
icon: <HandIcon />,
72-
name: 'Hand',
73-
ranking: lb.hand_leaders,
74-
},
75-
{
76-
id: 'brain',
77-
icon: <BrainIcon />,
78-
name: 'Brain',
79-
ranking: lb.brain_leaders,
80-
},
81-
])
82-
setLoading(false)
83-
}, [])
84-
8546
useEffect(() => {
86-
fetchLeaderboard()
47+
;(async () => {
48+
setLoading(true)
49+
const lb = await fetchLeaderboard()
50+
setLastUpdated(new Date(lb.last_updated + 'Z'))
51+
setLeaderboard([
52+
{
53+
id: 'regular',
54+
icon: <RegularPlayIcon />,
55+
name: 'Regular',
56+
ranking: lb.play_leaders,
57+
},
58+
{
59+
id: 'puzzles',
60+
icon: <TrainIcon />,
61+
name: 'Puzzles',
62+
ranking: lb.puzzles_leaders,
63+
},
64+
{
65+
id: 'turing',
66+
icon: <BotOrNotIcon />,
67+
name: 'Bot/Not',
68+
ranking: lb.turing_leaders,
69+
},
70+
{
71+
id: 'hand',
72+
icon: <HandIcon />,
73+
name: 'Hand',
74+
ranking: lb.hand_leaders,
75+
},
76+
{
77+
id: 'brain',
78+
icon: <BrainIcon />,
79+
name: 'Brain',
80+
ranking: lb.brain_leaders,
81+
},
82+
])
83+
setLoading(false)
84+
})()
8785
}, [fetchLeaderboard])
8886

8987
const containerVariants = {

0 commit comments

Comments
 (0)