habitica/common/script/ops/clearCompleted.js

13 lines
355 B
JavaScript
Raw Normal View History

2016-03-07 22:02:42 +00:00
import _ from 'lodash';
module.exports = function(user, req, cb) {
_.remove(user.todos, function(t) {
var ref;
return t.completed && !((ref = t.challenge) != null ? ref.id : void 0);
});
if (typeof user.markModified === "function") {
user.markModified('todos');
}
return typeof cb === "function" ? cb(null, user.todos) : void 0;
};