mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Fixing Duplicate tasks showing up after joining a challenge (#7787)
* fix: prevents double joining challenge by quickly hitting join button on challenge twice. fixes #7730 * Fixing client side parameter updates.
This commit is contained in:
@@ -79,8 +79,11 @@ schema.methods.syncToUser = async function syncChallengeToUser (user) {
|
||||
challenge.shortName = challenge.shortName || challenge.name;
|
||||
|
||||
// Add challenge to user.challenges
|
||||
if (!_.contains(user.challenges, challenge._id)) user.challenges.push(challenge._id);
|
||||
|
||||
if (!_.contains(user.challenges, challenge._id)) {
|
||||
// using concat because mongoose's protection against concurrent array modification isn't working as expected.
|
||||
// see https://github.com/HabitRPG/habitrpg/pull/7787#issuecomment-232972394
|
||||
user.challenges = user.challenges.concat([challenge._id]);
|
||||
}
|
||||
// Sync tags
|
||||
let userTags = user.tags;
|
||||
let i = _.findIndex(userTags, {id: challenge._id});
|
||||
|
||||
Reference in New Issue
Block a user