From bc53d88408f42a27acaa04132850c16ecbb40c2d Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 10 Sep 2021 19:44:00 -0500 Subject: make the zones api include unvisited zones --- build/cleaners/skyblock/member.js | 2 +- build/cleaners/skyblock/zones.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'build') diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js index 2242828..3a6a143 100644 --- a/build/cleaners/skyblock/member.js +++ b/build/cleaners/skyblock/member.js @@ -47,7 +47,7 @@ export async function cleanSkyBlockProfileMemberResponse(member, included = unde inventories: inventoriesIncluded ? await cleanInventories(member) : undefined, objectives: cleanObjectives(member), skills: await cleanSkills(member), - visited_zones: cleanVisitedZones(member), + visited_zones: await cleanVisitedZones(member), collections: cleanCollections(member), slayers: cleanSlayers(member) }; diff --git a/build/cleaners/skyblock/zones.js b/build/cleaners/skyblock/zones.js index ef7015e..90c689b 100644 --- a/build/cleaners/skyblock/zones.js +++ b/build/cleaners/skyblock/zones.js @@ -1,12 +1,23 @@ -export function cleanVisitedZones(data) { +import * as constants from '../../constants.js'; +export async function cleanVisitedZones(data) { const rawZones = data?.visited_zones || []; // TODO: store all the zones that exist in SkyBlock, add add those to the array with visited being false const zones = []; - for (const rawZoneName of rawZones) { + const knownZones = await constants.fetchZones(); + for (const rawZoneName of knownZones) { zones.push({ name: rawZoneName, - visited: true + visited: rawZones.includes(rawZoneName) }); } + // if this user somehow has a zone that we don't know about, just add it to zones + for (const rawZoneName of rawZones) { + if (!knownZones.includes(rawZoneName)) { + zones.push({ + name: rawZoneName, + visited: true + }); + } + } return zones; } -- cgit