mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
v3 client: misc fixes
This commit is contained in:
@@ -289,7 +289,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (spell.target == 'tasks') {
|
} else if (spell.target == 'tasks') {
|
||||||
var tasks = User.user.habits.concat(User.user.dailys).concat(User.user.rewards);
|
var tasks = User.user.habits.concat(User.user.dailys).concat(User.user.rewards).concat(User.user.todos);
|
||||||
// exclude challenge tasks
|
// exclude challenge tasks
|
||||||
tasks = tasks.filter(function (t) {
|
tasks = tasks.filter(function (t) {
|
||||||
if (!t.challenge) return true;
|
if (!t.challenge) return true;
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ habitrpg.controller('SettingsCtrl',
|
|||||||
|
|
||||||
$scope.reset = function(){
|
$scope.reset = function(){
|
||||||
User.reset({});
|
User.reset({});
|
||||||
|
User.sync();
|
||||||
$rootScope.$state.go('tasks');
|
$rootScope.$state.go('tasks');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ angular.module('habitrpg')
|
|||||||
clearCards: clearCards,
|
clearCards: clearCards,
|
||||||
}
|
}
|
||||||
|
|
||||||
//@TOOD: Port when User service is updated
|
|
||||||
function clearCards() {
|
function clearCards() {
|
||||||
User.user.ops.update && User.set({'flags.cardReceived':false});
|
User.user._wrapped && User.set({'flags.cardReceived':false});
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -264,8 +264,8 @@ function($rootScope, User, $timeout, $state, Analytics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Init and show the welcome tour (only after user is pulled from server & wrapped).
|
//Init and show the welcome tour (only after user is pulled from server & wrapped).
|
||||||
var watcher = $rootScope.$watch('User.user.ops.update', function(updateFn){
|
var watcher = $rootScope.$watch('User.user._wrapped', function(wrapped){
|
||||||
if (!updateFn) return; // only run after user has been wrapped
|
if (!wrapped) return; // only run after user has been wrapped
|
||||||
watcher(); // deregister watcher
|
watcher(); // deregister watcher
|
||||||
if (window.env.IS_MOBILE) return; // Don't show tour immediately on mobile devices
|
if (window.env.IS_MOBILE) return; // Don't show tour immediately on mobile devices
|
||||||
if (User.user.flags.welcomed == false) {
|
if (User.user.flags.welcomed == false) {
|
||||||
|
|||||||
@@ -61,21 +61,13 @@ angular.module('habitrpg')
|
|||||||
// replicated. We need to wrap each op to provide a callback to send that operation
|
// replicated. We need to wrap each op to provide a callback to send that operation
|
||||||
$window.habitrpgShared.wrap(user);
|
$window.habitrpgShared.wrap(user);
|
||||||
_.each(user.ops, function(op,k){
|
_.each(user.ops, function(op,k){
|
||||||
user.ops[k] = function(req,cb){
|
user.ops[k] = function(req){
|
||||||
if (cb) return op(req,cb);
|
try {
|
||||||
op(req,function(err,response) {
|
op(req);
|
||||||
for(var updatedItem in req.body) {
|
} catch (err) {
|
||||||
var itemUpdateResponse = userNotifications[updatedItem];
|
Notification.text(err.message);
|
||||||
if(itemUpdateResponse) Notification.text(itemUpdateResponse);
|
return;
|
||||||
}
|
}
|
||||||
if (err) {
|
|
||||||
var message = err.code ? err.message : err;
|
|
||||||
Notification.text(message);
|
|
||||||
// In the case of 200s, they're friendly alert messages like "Your pet has hatched!" - still send the op
|
|
||||||
if ((err.code && err.code >= 400) || !err.code) return;
|
|
||||||
}
|
|
||||||
userServices.log({op:k, params: req.params, query:req.query, body:req.body});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -106,13 +98,27 @@ angular.module('habitrpg')
|
|||||||
function callOpsFunctionAndRequest (opName, endPoint, method, paramString, opData) {
|
function callOpsFunctionAndRequest (opName, endPoint, method, paramString, opData) {
|
||||||
if (!opData) opData = {};
|
if (!opData) opData = {};
|
||||||
|
|
||||||
|
var clientResponse;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$window.habitrpgShared.ops[opName](user, opData);
|
var args = [user];
|
||||||
} catch(err) {
|
if (opName === 'rebirth' || opName === 'reroll' || opName === 'reset') {
|
||||||
|
args.push(user.habits.concat(user.dailys).concat(user.rewards).concat(user.todos));
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push(opData);
|
||||||
|
clientResponse = $window.habitrpgShared.ops[opName].apply(null, args);
|
||||||
|
} catch (err) {
|
||||||
Notification.text(err.message);
|
Notification.text(err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var clientMessage = clientResponse[1];
|
||||||
|
|
||||||
|
if (clientMessage) {
|
||||||
|
Notification.text(clientMessage);
|
||||||
|
}
|
||||||
|
|
||||||
var url = '/api/v3/user/' + endPoint;
|
var url = '/api/v3/user/' + endPoint;
|
||||||
if (paramString) {
|
if (paramString) {
|
||||||
url += '/' + paramString
|
url += '/' + paramString
|
||||||
@@ -130,7 +136,7 @@ angular.module('habitrpg')
|
|||||||
body: body,
|
body: body,
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (response.data.message) Notification.text(response.data.message);
|
if (response.data.message && response.data.message !== clientMessage) Notification.text(response.data.message);
|
||||||
save();
|
save();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -182,7 +188,12 @@ angular.module('habitrpg')
|
|||||||
},
|
},
|
||||||
|
|
||||||
score: function (data) {
|
score: function (data) {
|
||||||
|
try {
|
||||||
$window.habitrpgShared.ops.scoreTask({user: user, task: data.params.task, direction: data.params.direction}, data.params);
|
$window.habitrpgShared.ops.scoreTask({user: user, task: data.params.task, direction: data.params.direction}, data.params);
|
||||||
|
} catch (err) {
|
||||||
|
Notification.text(err.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
save();
|
save();
|
||||||
Tasks.scoreTask(data.params.task._id, data.params.direction).then(function (res) {
|
Tasks.scoreTask(data.params.task._id, data.params.direction).then(function (res) {
|
||||||
var tmp = res.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses
|
var tmp = res.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses
|
||||||
|
|||||||
Reference in New Issue
Block a user