From ebdca760e6cf960c0b805346c799022bcb5ac770 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 11 Aug 2025 08:08:47 -0700 Subject: [PATCH] chore: simplify syncing of challenge 'Completed' field (#2603) Challenges are mostly client-authoritative, so narrow the special-casing to "challengeRewards". Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2603 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/services/inventoryService.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 68cffb4b..c6c9d73b 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1980,17 +1980,20 @@ export const addChallenges = async ( dbChallenge.Completed ??= []; for (const completion of Completed!) { if (dbChallenge.Completed.indexOf(completion) == -1) { + dbChallenge.Completed.push(completion); if (completion == "challengeRewards") { if (Name in challengeRewardsInboxMessages) { await createMessage(account._id, [challengeRewardsInboxMessages[Name]]); - dbChallenge.Completed.push(completion); // Would love to somehow let the client know about inbox or inventory changes, but there doesn't seem to anything for updateChallengeProgress. continue; } + logger.warn(`ignoring unknown challenge completion`, { challenge: Name, completion }); + dbChallenge.Completed = []; } - logger.warn(`ignoring unknown challenge completion`, { challenge: Name, completion }); } } + } else { + dbChallenge.Completed = Completed; } }