feat: update compare achievement response

This commit is contained in:
Zamitto
2024-10-20 14:37:30 -03:00
parent 1d7858438d
commit 33e91e2007
6 changed files with 43 additions and 29 deletions

View File

@@ -22,10 +22,10 @@ const getComparedUnlockedAchievements = async (
}
).then((achievements) => {
const sortedAchievements = achievements.achievements.sort((a, b) => {
if (a.otherUserStat.unlocked && !b.otherUserStat.unlocked) return -1;
if (!a.otherUserStat.unlocked && b.otherUserStat.unlocked) return 1;
if (a.otherUserStat.unlocked && b.otherUserStat.unlocked) {
return b.otherUserStat.unlockTime! - a.otherUserStat.unlockTime!;
if (a.targetStat.unlocked && !b.targetStat.unlocked) return -1;
if (!a.targetStat.unlocked && b.targetStat.unlocked) return 1;
if (a.targetStat.unlocked && b.targetStat.unlocked) {
return b.targetStat.unlockTime! - a.targetStat.unlockTime!;
}
return Number(a.hidden) - Number(b.hidden);