From b42182c85fb365a29f4f05de6be7e31852b3487a Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 25 Jun 2025 20:22:24 -0700 Subject: [PATCH] fix(webui): handle existing entries for unlock all missions (#2290) Closes #2283 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2290 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- .../custom/completeAllMissionsController.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/controllers/custom/completeAllMissionsController.ts b/src/controllers/custom/completeAllMissionsController.ts index 2e7ac2fb..f6ab486d 100644 --- a/src/controllers/custom/completeAllMissionsController.ts +++ b/src/controllers/custom/completeAllMissionsController.ts @@ -12,18 +12,24 @@ export const completeAllMissionsController: RequestHandler = async (req, res) => const inventory = await getInventory(accountId); const MissionRewards: IMissionReward[] = []; for (const [tag, node] of Object.entries(ExportRegions)) { - if (!inventory.Missions.find(x => x.Tag == tag)) { - inventory.Missions.push({ - Completes: 1, - Tier: 1, - Tag: tag - }); - + let mission = inventory.Missions.find(x => x.Tag == tag); + if (!mission) { + mission = + inventory.Missions[ + inventory.Missions.push({ + Completes: 0, + Tier: 0, + Tag: tag + }) - 1 + ]; + } + if (mission.Completes == 0) { + mission.Completes++; if (node.missionReward) { - console.log(node.missionReward); addFixedLevelRewards(node.missionReward, inventory, MissionRewards); } } + mission.Tier = 1; } for (const reward of MissionRewards) { await handleStoreItemAcquisition(reward.StoreItem, inventory, reward.ItemCount, undefined, true);