port updateTask, addTask, clearCompleted, taskDefaults, uuid

This commit is contained in:
Matteo Pagliazzi
2016-04-03 21:50:32 +02:00
parent 060e3b1045
commit 382e391fd0
14 changed files with 322 additions and 99 deletions

View File

@@ -1,12 +1,10 @@
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);
// TODO move to client since it's only used there?
// TODO rename file to clearCompletedTodos
module.exports = function clearCompletedTodos (todos) {
_.remove(todos, todo => {
return todo.completed && (!todo.challenge || !todo.challenge.id || todo.challenge.broken);
});
if (typeof user.markModified === "function") {
user.markModified('todos');
}
return typeof cb === "function" ? cb(null, user.todos) : void 0;
};