Updated login headers save. Added task service to user service. Sync user tasks

This commit is contained in:
Keith Holliday
2016-05-09 23:31:34 -05:00
parent a92359e119
commit a0939155c9
13 changed files with 107 additions and 86 deletions

View File

@@ -5,6 +5,7 @@ import taskDefaults from '../libs/taskDefaults';
module.exports = function addTask (user, req = {body: {}}) { module.exports = function addTask (user, req = {body: {}}) {
let task = taskDefaults(req.body); let task = taskDefaults(req.body);
user.tasksOrder[`${task.type}s`].unshift(task._id); user.tasksOrder[`${task.type}s`].unshift(task._id);
user[`${task.type}s`].unshift(task);
if (user.preferences.newTaskEdit) { if (user.preferences.newTaskEdit) {
task._editing = true; task._editing = true;

View File

@@ -6,16 +6,15 @@ import _ from 'lodash';
module.exports = function deleteTask (user, req = {}) { module.exports = function deleteTask (user, req = {}) {
let tid = _.get(req, 'params.id'); let tid = _.get(req, 'params.id');
let task = user.tasks[tid]; let taskType = _.get(req, 'params.taskType');
if (!task) { let index = _.findIndex(user[`${taskType}s`], function(task) {return task._id === tid;});
if (index === -1) {
throw new NotFound(i18n.t('messageTaskNotFound', req.language)); throw new NotFound(i18n.t('messageTaskNotFound', req.language));
} }
let index = user[`${task.type}s`].indexOf(task); user[`${taskType}s`].splice(index, 1);
if (index !== -1) {
user[`${task.type}s`].splice(index, 1);
}
return {}; return {};
}; };

View File

@@ -8,23 +8,24 @@ import _ from 'lodash';
// TODO used only in client, move there? // TODO used only in client, move there?
module.exports = function sortTag (user, req = {}) { module.exports = function sortTask (user, req = {}) {
let id = _.get(req, 'params.id'); let id = _.get(req, 'params.id');
let to = _.get(req, 'query.to'); let to = _.get(req, 'query.to');
let fromParam = _.get(req, 'query.from'); let fromParam = _.get(req, 'query.from');
let taskType = _.get(req, 'params.taskType');
let task = user.tasks[id]; let index = _.findIndex(user[`${taskType}s`], function(task) {return task._id === id;});
if (!task) { if (index === -1) {
throw new NotFound(i18n.t('messageTaskNotFound', req.language)); throw new NotFound(i18n.t('messageTaskNotFound', req.language));
} }
if (!to && !fromParam) { if (!to && !fromParam) {
throw new BadRequest('?to=__&from=__ are required'); throw new BadRequest('?to=__&from=__ are required');
} }
let tasks = user[`${task.type}s`]; let tasks = user[`${taskType}s`];
if (task.type === 'todo' && tasks[fromParam] !== task) { if (taskType === 'todo') {
let preenedTasks = preenTodos(tasks); let preenedTasks = preenTodos(tasks);
if (to !== -1) { if (to !== -1) {
@@ -34,10 +35,6 @@ module.exports = function sortTag (user, req = {}) {
fromParam = tasks.indexOf(preenedTasks[fromParam]); fromParam = tasks.indexOf(preenedTasks[fromParam]);
} }
if (tasks[fromParam] !== task) {
throw new NotFound(i18n.t('messageTaskNotFound', req.language));
}
let movedTask = tasks.splice(fromParam, 1)[0]; let movedTask = tasks.splice(fromParam, 1)[0];
if (to === -1) { if (to === -1) {

View File

@@ -310,6 +310,7 @@ window.habitrpg = angular.module('habitrpg',
}); });
var settings = JSON.parse(localStorage.getItem(STORAGE_SETTINGS_ID)); var settings = JSON.parse(localStorage.getItem(STORAGE_SETTINGS_ID));
if (settings && settings.auth) { if (settings && settings.auth) {
$httpProvider.defaults.headers.common['Content-Type'] = 'application/json;charset=utf-8'; $httpProvider.defaults.headers.common['Content-Type'] = 'application/json;charset=utf-8';
$httpProvider.defaults.headers.common['x-api-user'] = settings.auth.apiId; $httpProvider.defaults.headers.common['x-api-user'] = settings.auth.apiId;

View File

@@ -64,7 +64,7 @@ angular.module('habitrpg')
}).error(errorAlert); }).error(errorAlert);
}; };
$scope.playButtonClick = function(){ $scope.playButtonClick = function() {
Analytics.track({'hitType':'event','eventCategory':'button','eventAction':'click','eventLabel':'Play'}) Analytics.track({'hitType':'event','eventCategory':'button','eventAction':'click','eventLabel':'Play'})
if (User.authenticated()) { if (User.authenticated()) {
window.location.href = ('/' + window.location.hash); window.location.href = ('/' + window.location.hash);

View File

@@ -14,7 +14,7 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared',
_.each(User.user.tags, function(tag){ _.each(User.user.tags, function(tag){
// Send an update op for each changed tag (excluding new tags & deleted tags, this if() packs a punch) // Send an update op for each changed tag (excluding new tags & deleted tags, this if() packs a punch)
if (tagsSnap[tag.id] && tagsSnap[tag.id].name != tag.name) if (tagsSnap[tag.id] && tagsSnap[tag.id].name != tag.name)
User.updateTag({params:{id:tag.id},body:{name:tag.name}}); User.updateTag({params:{id:tag.id}, body:{name:tag.name}});
}) })
$scope._editing = false; $scope._editing = false;
} else { } else {
@@ -37,7 +37,7 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared',
$scope.updateTaskFilter(); $scope.updateTaskFilter();
$scope.createTag = function() { $scope.createTag = function() {
User.addTag({body:{name:$scope._newTag.name, id:Shared.uuid()}}); User.addTag({body:{name: $scope._newTag.name, id: Shared.uuid()}});
$scope._newTag.name = ''; $scope._newTag.name = '';
}; };
}]); }]);

View File

@@ -24,7 +24,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
if (direction === 'down') $rootScope.playSound('Minus_Habit'); if (direction === 'down') $rootScope.playSound('Minus_Habit');
else if (direction === 'up') $rootScope.playSound('Plus_Habit'); else if (direction === 'up') $rootScope.playSound('Plus_Habit');
} }
User.score({params:{id: task.id, direction:direction}}); User.score({params:{task: task, direction:direction}});
Analytics.updateUser(); Analytics.updateUser();
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'score task','taskType':task.type,'direction':direction}); Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'score task','taskType':task.type,'direction':direction});
}; };
@@ -33,12 +33,12 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
var newTask = { var newTask = {
text: task, text: task,
type: listDef.type, type: listDef.type,
tags: _.transform(User.user.filters, function(m, v, k) { // tags: _.transform(User.user.filters, function(m, v, k) {
if (v) m.push(v); // if (v) m.push(v);
}), // }),
}; };
User.addTask({body:newTask}); User.addTask({body: newTask});
} }
$scope.addTask = function(addTo, listDef) { $scope.addTask = function(addTo, listDef) {
@@ -80,7 +80,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
*/ */
$scope.pushTask = function(task, index, location) { $scope.pushTask = function(task, index, location) {
var to = (location === 'bottom' || $scope.ctrlPressed) ? -1 : 0; var to = (location === 'bottom' || $scope.ctrlPressed) ? -1 : 0;
User.sortTask({params:{id:task.id},query:{from:index, to:to}}) User.sortTask({params:{id: task._id, taskType: task.type}, query:{from:index, to:to}})
}; };
/** /**
@@ -96,17 +96,17 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
$scope.removeTask = function(task) { $scope.removeTask = function(task) {
if (!confirm(window.env.t('sureDelete', {taskType: window.env.t(task.type), taskText: task.text}))) return; if (!confirm(window.env.t('sureDelete', {taskType: window.env.t(task.type), taskText: task.text}))) return;
User.deleteTask({params:{id:task.id}}) User.deleteTask({params:{id: task._id, taskType: task.type}})
}; };
$scope.saveTask = function(task, stayOpen, isSaveAndClose) { $scope.saveTask = function(task, stayOpen, isSaveAndClose) {
if (task.checklist) if (task.checklist)
task.checklist = _.filter(task.checklist,function(i){return !!i.text}); task.checklist = _.filter(task.checklist,function(i){return !!i.text});
User.updateTask({params:{id:task.id},body:task}); User.updateTask(task, {body: task});
if (!stayOpen) task._editing = false; if (!stayOpen) task._editing = false;
if (isSaveAndClose) { if (isSaveAndClose) {
$("#task-" + task.id).parent().children('.popover').removeClass('in'); $("#task-" + task._id).parent().children('.popover').removeClass('in');
} }
if (task.type == 'habit') Guide.goto('intro', 3); if (task.type == 'habit') Guide.goto('intro', 3);
@@ -126,7 +126,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
}; };
$scope.unlink = function(task, keep) { $scope.unlink = function(task, keep) {
Tasks.unlinkTask(task.id, keep) Tasks.unlinkTask(task._id, keep)
.success(function () { .success(function () {
User.log({}); User.log({});
}); });
@@ -159,7 +159,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
*/ */
function focusChecklist(task,index) { function focusChecklist(task,index) {
window.setTimeout(function(){ window.setTimeout(function(){
$('#task-'+task.id+' .checklist-form input[type="text"]')[index].focus(); $('#task-'+task._id+' .checklist-form input[type="text"]')[index].focus();
}); });
} }
@@ -173,7 +173,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
// Don't allow creation of an empty checklist item // Don't allow creation of an empty checklist item
// TODO Provide UI feedback that this item is still blank // TODO Provide UI feedback that this item is still blank
} else if ($index == task.checklist.length-1){ } else if ($index == task.checklist.length-1){
User.updateTask({params:{id:task.id},body:task}); // don't preen the new empty item User.updateTask({params:{id:task._id},body:task}); // don't preen the new empty item
task.checklist.push({completed:false,text:''}); task.checklist.push({completed:false,text:''});
focusChecklist(task,task.checklist.length-1); focusChecklist(task,task.checklist.length-1);
} else { } else {
@@ -185,12 +185,12 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
$scope.removeChecklistItem = function(task, $event, $index, force){ $scope.removeChecklistItem = function(task, $event, $index, force){
// Remove item if clicked on trash icon // Remove item if clicked on trash icon
if (force) { if (force) {
Tasks.removeChecklistItem(task.id, task.checklist[$index]._id); Tasks.removeChecklistItem(task._id, task.checklist[$index]._id);
task.checklist.splice($index, 1); task.checklist.splice($index, 1);
} else if (!task.checklist[$index].text) { } else if (!task.checklist[$index].text) {
// User deleted all the text and is now wishing to delete the item // User deleted all the text and is now wishing to delete the item
// saveTask will prune the empty item // saveTask will prune the empty item
Tasks.removeChecklistItem(task.id, task.checklist[$index]._id); Tasks.removeChecklistItem(task._id, task.checklist[$index]._id);
// Move focus if the list is still non-empty // Move focus if the list is still non-empty
if ($index > 0) if ($index > 0)
focusChecklist(task, $index-1); focusChecklist(task, $index-1);

View File

@@ -16,7 +16,7 @@
ui.item.data('startIndex', ui.item.index()); ui.item.data('startIndex', ui.item.index());
}, },
stop: function (event, ui) { stop: function (event, ui) {
User.user.ops.sortTag({ User.sortTag({
query: { query: {
from: ui.item.data('startIndex'), from: ui.item.data('startIndex'),
to:ui.item.index() to:ui.item.index()

View File

@@ -20,8 +20,8 @@
stop: function (event, ui) { stop: function (event, ui) {
var task = angular.element(ui.item[0]).scope().task; var task = angular.element(ui.item[0]).scope().task;
var startIndex = ui.item.data('startIndex'); var startIndex = ui.item.data('startIndex');
User.user.ops.sortTask({ User.sortTask({
params: { id: task.id }, params: { id: task._id, taskType: task.type },
query: { query: {
from: startIndex, from: startIndex,
to: ui.item.index() to: ui.item.index()

View File

@@ -3,20 +3,20 @@
var TASK_KEYS_TO_REMOVE = ['_id', 'completed', 'date', 'dateCompleted', 'history', 'id', 'streak', 'createdAt']; var TASK_KEYS_TO_REMOVE = ['_id', 'completed', 'date', 'dateCompleted', 'history', 'id', 'streak', 'createdAt'];
angular.module('habitrpg') angular.module('habitrpg')
.factory('Tasks', ['$rootScope', 'Shared', 'User', '$http', .factory('Tasks', ['$rootScope', 'Shared', '$http',
function tasksFactory($rootScope, Shared, User, $http) { function tasksFactory($rootScope, Shared, $http) {
function getUserTasks () { function getUserTasks () {
return $http({ return $http({
method: 'GET', method: 'GET',
url: 'api/v3/tasks/user', url: '/api/v3/tasks/user',
}); });
}; };
function createUserTasks (taskDetails) { function createUserTasks (taskDetails) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/user', url: '/api/v3/tasks/user',
data: taskDetails, data: taskDetails,
}); });
}; };
@@ -24,14 +24,14 @@ angular.module('habitrpg')
function getChallengeTasks (challengeId) { function getChallengeTasks (challengeId) {
return $http({ return $http({
method: 'GET', method: 'GET',
url: 'api/v3/tasks/challenge/' + challengeId, url: '/api/v3/tasks/challenge/' + challengeId,
}); });
}; };
function createChallengeTasks (challengeId, taskDetails) { function createChallengeTasks (challengeId, taskDetails) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/challenge/' + challengeId, url: '/api/v3/tasks/challenge/' + challengeId,
data: taskDetails, data: taskDetails,
}); });
}; };
@@ -39,14 +39,14 @@ angular.module('habitrpg')
function getTask (taskId) { function getTask (taskId) {
return $http({ return $http({
method: 'GET', method: 'GET',
url: 'api/v3/tasks/' + taskId, url: '/api/v3/tasks/' + taskId,
}); });
}; };
function updateTask (taskId, taskDetails) { function updateTask (taskId, taskDetails) {
return $http({ return $http({
method: 'PUT', method: 'PUT',
url: 'api/v3/tasks/' + taskId, url: '/api/v3/tasks/' + taskId,
data: taskDetails, data: taskDetails,
}); });
}; };
@@ -54,28 +54,28 @@ angular.module('habitrpg')
function deleteTask (taskId) { function deleteTask (taskId) {
return $http({ return $http({
method: 'DELETE', method: 'DELETE',
url: 'api/v3/tasks/' + taskId, url: '/api/v3/tasks/' + taskId,
}); });
}; };
function scoreTask (taskId, direction) { function scoreTask (taskId, direction) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/' + taskId + '/score/' + direction, url: '/api/v3/tasks/' + taskId + '/score/' + direction,
}); });
}; };
function moveTask (taskId, position) { function moveTask (taskId, position) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/' + taskId + '/move/to/' + position, url: '/api/v3/tasks/' + taskId + '/move/to/' + position,
}); });
}; };
function addChecklistItem (taskId, checkListItem) { function addChecklistItem (taskId, checkListItem) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/' + taskId + '/checklist', url: '/api/v3/tasks/' + taskId + '/checklist',
data: checkListItem, data: checkListItem,
}); });
}; };
@@ -83,14 +83,14 @@ angular.module('habitrpg')
function scoreCheckListItem (taskId, itemId) { function scoreCheckListItem (taskId, itemId) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/' + taskId + '/checklist/' + itemId + '/score', url: '/api/v3/tasks/' + taskId + '/checklist/' + itemId + '/score',
}); });
}; };
function updateChecklistItem (taskId, itemId, itemDetails) { function updateChecklistItem (taskId, itemId, itemDetails) {
return $http({ return $http({
method: 'PUT', method: 'PUT',
url: 'api/v3/tasks/' + taskId + '/checklist/' + itemId, url: '/api/v3/tasks/' + taskId + '/checklist/' + itemId,
data: itemDetails, data: itemDetails,
}); });
}; };
@@ -98,21 +98,21 @@ angular.module('habitrpg')
function removeChecklistItem (taskId, itemId) { function removeChecklistItem (taskId, itemId) {
return $http({ return $http({
method: 'DELETE', method: 'DELETE',
url: 'api/v3/tasks/' + taskId + '/checklist/' + itemId, url: '/api/v3/tasks/' + taskId + '/checklist/' + itemId,
}); });
}; };
function addTagToTask (taskId, tagId) { function addTagToTask (taskId, tagId) {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/' + taskId + '/tags/' + tagId, url: '/api/v3/tasks/' + taskId + '/tags/' + tagId,
}); });
}; };
function removeTagFromTask (taskId, tagId) { function removeTagFromTask (taskId, tagId) {
return $http({ return $http({
method: 'DELETE', method: 'DELETE',
url: 'api/v3/tasks/' + taskId + '/tags/' + tagId, url: '/api/v3/tasks/' + taskId + '/tags/' + tagId,
}); });
}; };
@@ -123,21 +123,21 @@ angular.module('habitrpg')
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/unlink/' + taskId + '?keep=' + keep, url: '/api/v3/tasks/unlink/' + taskId + '?keep=' + keep,
}); });
}; };
function clearCompletedTodos () { function clearCompletedTodos () {
return $http({ return $http({
method: 'POST', method: 'POST',
url: 'api/v3/tasks/clearCompletedTodos', url: '/api/v3/tasks/clearCompletedTodos',
}); });
}; };
function editTask(task) { function editTask(task) {
task._editing = !task._editing; task._editing = !task._editing;
task._tags = !User.user.preferences.tagsCollapsed; // task._tags = !User.user.preferences.tagsCollapsed;
task._advanced = !User.user.preferences.advancedCollapsed; // task._advanced = !User.user.preferences.advancedCollapsed;
if($rootScope.charts[task.id]) $rootScope.charts[task.id] = false; if($rootScope.charts[task.id]) $rootScope.charts[task.id] = false;
} }

View File

@@ -14,8 +14,8 @@ angular.module('habitrpg')
/** /**
* Services that persists and retrieves user from localStorage. * Services that persists and retrieves user from localStorage.
*/ */
.factory('User', ['$rootScope', '$http', '$location', '$window', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'Notification', 'ApiUrl', .factory('User', ['$rootScope', '$http', '$location', '$window', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'Notification', 'ApiUrl', 'Tasks',
function($rootScope, $http, $location, $window, STORAGE_USER_ID, STORAGE_SETTINGS_ID, Notification, ApiUrl) { function($rootScope, $http, $location, $window, STORAGE_USER_ID, STORAGE_SETTINGS_ID, Notification, ApiUrl, Tasks) {
var authenticated = false; var authenticated = false;
var defaultSettings = { var defaultSettings = {
auth: { apiId: '', apiToken: ''}, auth: { apiId: '', apiToken: ''},
@@ -48,7 +48,7 @@ angular.module('habitrpg')
function sync() { function sync() {
$http({ $http({
method: "GET", method: "GET",
url: 'api/v3/user/', url: '/api/v3/user/',
}) })
.then(function (response) { .then(function (response) {
if (response.data.message) Notification.text(response.data.message); if (response.data.message) Notification.text(response.data.message);
@@ -82,7 +82,19 @@ angular.module('habitrpg')
save(); save();
$rootScope.$emit('userSynced'); $rootScope.$emit('userSynced');
return Tasks.getUserTasks();
}) })
.then(function (response) {
var tasks = response.data.data;
user.habits = [];
user.todos = [];
user.dailys = [];
user.rewards = [];
tasks.forEach(function (element, index, array) {
user[element.type + 's'].push(element)
})
});
} }
sync(); sync();
@@ -95,7 +107,7 @@ angular.module('habitrpg')
if (!opData) opData = {}; if (!opData) opData = {};
$window.habitrpgShared.ops[opName](user, opData); $window.habitrpgShared.ops[opName](user, opData);
var url = 'api/v3/user/' + endPoint; var url = '/api/v3/user/' + endPoint;
if (paramString) { if (paramString) {
url += '/' + paramString url += '/' + paramString
} }
@@ -119,7 +131,7 @@ angular.module('habitrpg')
function setUser(updates) { function setUser(updates) {
for (var key in updates) { for (var key in updates) {
user[key] = updates[key]; _.set(user, key, updates[key]);
} }
} }
@@ -135,46 +147,53 @@ angular.module('habitrpg')
}, },
addTask: function (data) { addTask: function (data) {
//@TODO: Should this been on habitrpgShared?
user.ops.addTask(data); user.ops.addTask(data);
save(); save();
//@TODO: Call task service when PR is merged Tasks.createUserTasks(data.body);
}, },
score: function (data) { score: function (data) {
user.ops.scoreTask(data); $window.habitrpgShared.ops.scoreTask({user: user, task: data.params.task, direction: data.params.direction}, data.params);
save(); save();
//@TODO: Call task service when PR is merged Tasks.scoreTask(data.params.task._id, data.params.direction);
}, },
sortTask: function (data) { sortTask: function (data) {
user.ops.sortTask(data); user.ops.sortTask(data);
save(); save();
//@TODO: Call task service when PR is merged Tasks.moveTask(data.params.id, data.query.to);
}, },
updateTask: function (data) { updateTask: function (task, data) {
user.ops.updateTask(data); $window.habitrpgShared.ops.updateTask(task, data);
save(); save();
//@TODO: Call task service when PR is merged Tasks.updateTask(task._id, data.body);
}, },
deleteTask: function (data) { deleteTask: function (data) {
user.ops.deleteTask(data); user.ops.deleteTask(data);
save(); save();
//@TODO: Call task service when PR is merged Tasks.deleteTask(data.params.id);
}, },
addTag: function(data) { addTag: function(data) {
user.ops.addTag(data); user.ops.addTag(data);
save(); save();
//@TODO: Call task service when PR is merged $http({
method: "PUT",
url: '/api/v3/user',
data: {filters: user.filters},
});
}, },
updateTag: function(data) { updateTag: function(data) {
user.ops.updateTag(data); user.ops.updateTag(data);
save(); save();
//@TODO: Call task service when PR is merged $http({
method: "PUT",
url: '/api/v3/user',
data: {filters: user.filters},
});
}, },
addTenGems: function () { addTenGems: function () {
@@ -222,7 +241,7 @@ angular.module('habitrpg')
$http({ $http({
method: "POST", method: "POST",
url: 'api/v3/user/' + 'buy-special-spell/' + key, url: '/api/v3/user/' + 'buy-special-spell/' + key,
}) })
.then(function (response) { .then(function (response) {
Notification.text(response.data.message); Notification.text(response.data.message);
@@ -267,12 +286,9 @@ angular.module('habitrpg')
setUser(updates); setUser(updates);
$http({ $http({
method: "PUT", method: "PUT",
url: 'api/v3/user', url: '/api/v3/user',
data: updates, data: updates,
}) });
.then(function (response) {
sync();
})
}, },
reroll: function () { reroll: function () {
@@ -334,13 +350,18 @@ angular.module('habitrpg')
settings.auth.apiId = uuid; settings.auth.apiId = uuid;
settings.auth.apiToken = token; settings.auth.apiToken = token;
settings.online = true; settings.online = true;
if (user && user._v) user._v--; // shortcut to always fetch new updates on page reload save();
userServices.log({}, function(){ sync();
// If they don't have timezone, set it if (cb) {
if (user.preferences.timezoneOffset !== offset) cb();
userServices.set({'preferences.timezoneOffset': offset}); }
cb && cb(); //@TODO: Do we need the timezone set?
}); // userServices.log({}, function(){
// // If they don't have timezone, set it
// if (user.preferences.timezoneOffset !== offset)
// userServices.set({'preferences.timezoneOffset': offset});
// cb && cb();
// });
} else { } else {
alert('Please enter your ID and Token in settings.') alert('Please enter your ID and Token in settings.')
} }

View File

@@ -132,6 +132,7 @@
"js/services/sharedServices.js", "js/services/sharedServices.js",
"js/services/socialServices.js", "js/services/socialServices.js",
"js/services/statServices.js", "js/services/statServices.js",
"js/services/taskServices.js",
"js/services/userServices.js", "js/services/userServices.js",
"js/controllers/authCtrl.js", "js/controllers/authCtrl.js",
"js/controllers/footerCtrl.js" "js/controllers/footerCtrl.js"
@@ -166,6 +167,7 @@
"js/services/sharedServices.js", "js/services/sharedServices.js",
"js/services/socialServices.js", "js/services/socialServices.js",
"js/services/statServices.js", "js/services/statServices.js",
"js/services/taskServices.js",
"js/services/userServices.js", "js/services/userServices.js",
"js/controllers/authCtrl.js", "js/controllers/authCtrl.js",
"js/controllers/footerCtrl.js" "js/controllers/footerCtrl.js"

View File

@@ -8,7 +8,7 @@ div(ng-if='task._editing')
p p
a(ng-click='unlink(task, "keep")')=env.t('keepIt') a(ng-click='unlink(task, "keep")')=env.t('keepIt')
|    |   
a(ng-click="removeTask(task, obj")=env.t('removeIt') a(ng-click="removeTask(task, obj)")=env.t('removeIt')
div(ng-if='task.challenge.broken=="CHALLENGE_DELETED"') div(ng-if='task.challenge.broken=="CHALLENGE_DELETED"')
p p
|  |