chore: simplify syncing of challenge 'Completed' field (#2603)
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:
parent
51c0ddda38
commit
ebdca760e6
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user