diff options
author | mat <github@matdoes.dev> | 2022-03-29 15:30:33 +0000 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-29 15:30:33 +0000 |
commit | 7ac9e12332bba402d5ff2898735f331e5b291381 (patch) | |
tree | 91921d0aabfeff2591abf9e47f62e78dae6803c0 /src | |
parent | 394b163f7e4ae4ec05e0f507d4464f54cf57ce4b (diff) | |
download | skyblock-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.ts | 7 |
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) |