mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Client Fixed (#9017)
* fix spacing between rewards and items * fix rewards description * rewards cost in bold * fix gp notifications * fix dailies gray text * fix cancel in task edit modal * tags: use AND not OR for filtering * fix tasksDefaults so that monthlies can be created correctly * tags: usable if no task selected, saving checklist and tags saved the one being added without requiting to press enter * remove tags from tasks when they are deleted * fix tags removal when multiple tags are deleted and fix tags editing
This commit is contained in:
@@ -285,6 +285,8 @@ api.updateUser = {
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
|
||||
let promisesForTagsRemoval = [];
|
||||
|
||||
_.each(req.body, (val, key) => {
|
||||
let purchasable = requiresPurchase[key];
|
||||
|
||||
@@ -321,20 +323,26 @@ api.updateUser = {
|
||||
user.tags.push(Tag.sanitize(t));
|
||||
});
|
||||
|
||||
// Remove from all the tasks TODO test
|
||||
Tasks.Task.update({
|
||||
userId: user._id,
|
||||
}, {
|
||||
$pull: {
|
||||
tags: {$in: [removedTagsIds]},
|
||||
},
|
||||
}, {multi: true}).exec();
|
||||
// Remove from all the tasks
|
||||
// NOTE each tag to remove requires a query
|
||||
|
||||
promisesForTagsRemoval = removedTagsIds.map(tagId => {
|
||||
return Tasks.Task.update({
|
||||
userId: user._id,
|
||||
}, {
|
||||
$pull: {
|
||||
tags: tagId,
|
||||
},
|
||||
}, {multi: true}).exec();
|
||||
});
|
||||
} else {
|
||||
throw new NotAuthorized(res.t('messageUserOperationProtected', { operation: key }));
|
||||
}
|
||||
});
|
||||
|
||||
await user.save();
|
||||
|
||||
await Promise.all([user.save()].concat(promisesForTagsRemoval));
|
||||
|
||||
return res.respond(200, user);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user