fix score feed getting stuck
All checks were successful
Deploy Website / deploy (push) Successful in 8m21s

This commit is contained in:
Lee 2024-10-13 05:14:03 +01:00
parent aa4ef05b55
commit 4d27fe9bae

View File

@ -22,13 +22,9 @@ export default function ScoreFeed() {
}
setScores(prev => {
const newScores = [...prev, commandData];
if (newScores.length > 8) {
newScores.pop();
}
// Newest to oldest
return newScores.sort((a, b) => parseDate(b.score.timeSet).getTime() - parseDate(a.score.timeSet).getTime());
return [...prev, commandData]
.sort((a, b) => parseDate(b.score.timeSet).getTime() - parseDate(a.score.timeSet).getTime())
.slice(0, 8);
});
}, [lastJsonMessage]);