aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-03-29 15:30:33 +0000
committermat <github@matdoes.dev>2022-03-29 15:30:33 +0000
commit7ac9e12332bba402d5ff2898735f331e5b291381 (patch)
tree91921d0aabfeff2591abf9e47f62e78dae6803c0 /src
parent394b163f7e4ae4ec05e0f507d4464f54cf57ce4b (diff)
downloadskyblock-api-7ac9e12332bba402d5ff2898735f331e5b291381.tar.gz
skyblock-api-7ac9e12332bba402d5ff2898735f331e5b291381.tar.bz2
skyblock-api-7ac9e12332bba402d5ff2898735f331e5b291381.zip
sort profiles by last save probably
Diffstat (limited to 'src')
-rw-r--r--src/hypixelCached.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index 5a17c3c..6e634ef 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -247,6 +247,13 @@ export async function fetchSkyblockProfiles(playerUuid: string): Promise<CleanPr
basicProfiles.push(basicProfile)
}
+ basicProfiles.sort((a, b) => {
+ const memberA = a.members?.find(m => m.uuid === playerUuid)
+ const memberB = b.members?.find(m => m.uuid === playerUuid)
+ if (!memberA || !memberB || !memberA.lastSave || !memberB.lastSave) return 0
+ return memberB.lastSave - memberA.lastSave
+ })
+
// cache the profiles
profilesCache.set(playerUuid, basicProfiles)