From 84ef3fb86133bf9424ca760d1160b52dcee6df82 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 25 Dec 2013 10:56:21 -0700 Subject: [PATCH] API: better task defaults (for 3rd-party up/down scoring) --- dist/habitrpg-shared.js | 12 +++++++----- script/index.coffee | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 447f7028aa..85752f966e 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -10869,11 +10869,13 @@ var process=require("__browserify_process");(function() { api.taskDefaults = function(task) { - var defaults, _ref, _ref1; + var defaults, _ref, _ref1, _ref2; + if (!(task.type && ((_ref = task.type) === 'habit' || _ref === 'daily' || _ref === 'todo' || _ref === 'reward'))) { + task.type = 'habit'; + } defaults = { id: api.uuid(), - type: 'habit', - text: '', + text: task.id != null ? task.id : '', notes: '', priority: 1, challenge: {}, @@ -10886,12 +10888,12 @@ var process=require("__browserify_process");(function() { down: true }); } - if ((_ref = task.type) === 'habit' || _ref === 'daily') { + if ((_ref1 = task.type) === 'habit' || _ref1 === 'daily') { _.defaults(task, { history: [] }); } - if ((_ref1 = task.type) === 'daily' || _ref1 === 'todo') { + if ((_ref2 = task.type) === 'daily' || _ref2 === 'todo') { _.defaults(task, { completed: false }); diff --git a/script/index.coffee b/script/index.coffee index 6432d55b38..a0daa00bab 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -164,10 +164,10 @@ Even though Mongoose handles task defaults, we want to make sure defaults are se sending up to the server for performance ### api.taskDefaults = (task) -> + task.type = 'habit' unless task.type and task.type in ['habit','daily','todo','reward'] defaults = id: api.uuid() - type: 'habit' - text: '' + text: if task.id? then task.id else '' notes: '' priority: 1 challenge: {}