chore: simplify syncing of challenge 'Completed' field (#2603)
Some checks failed
Build Docker image / docker-arm64 (push) Waiting to run
Build Docker image / docker-amd64 (push) Has been cancelled
Build / build (push) Has been cancelled

Challenges are mostly client-authoritative, so narrow the special-casing to "challengeRewards".

Reviewed-on: #2603
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-08-11 08:08:47 -07:00 committed by Sainan
parent 51c0ddda38
commit ebdca760e6

View File

@ -1980,17 +1980,20 @@ export const addChallenges = async (
dbChallenge.Completed ??= []; dbChallenge.Completed ??= [];
for (const completion of Completed!) { for (const completion of Completed!) {
if (dbChallenge.Completed.indexOf(completion) == -1) { if (dbChallenge.Completed.indexOf(completion) == -1) {
dbChallenge.Completed.push(completion);
if (completion == "challengeRewards") { if (completion == "challengeRewards") {
if (Name in challengeRewardsInboxMessages) { if (Name in challengeRewardsInboxMessages) {
await createMessage(account._id, [challengeRewardsInboxMessages[Name]]); 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. // Would love to somehow let the client know about inbox or inventory changes, but there doesn't seem to anything for updateChallengeProgress.
continue; 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;
} }
} }