mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
[#1977] misc fixes
This commit is contained in:
@@ -75,15 +75,9 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', 'User', 'API_URL',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.hatch = function(egg, potion){
|
$scope.hatch = function(egg, potion){
|
||||||
user.ops.hatch({query:{egg:egg.name, hatchingPotion:potion.name}}, function(err, req){
|
user.ops.hatch({query:{egg:egg.name, hatchingPotion:potion.name}});
|
||||||
// Bypassing the UserServices-injected callback so we can only show alert on success. It's safe, since this means
|
$scope.selectedEgg = null;
|
||||||
// UserServices callback will be 3rd param and never get called
|
$scope.selectedPotion = null;
|
||||||
if (err) return Notification.text(err);
|
|
||||||
User.log({op:'hatch', query:req.query});
|
|
||||||
Notification.text("Your egg hatched! Visit your stable to equip your pet.");
|
|
||||||
$scope.selectedEgg = null;
|
|
||||||
$scope.selectedPotion = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.buy = function(type, item){
|
$scope.buy = function(type, item){
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ angular.module('userServices', []).
|
|||||||
$rootScope.Shared.wrap(user);
|
$rootScope.Shared.wrap(user);
|
||||||
_.each(user.ops, function(op,k){
|
_.each(user.ops, function(op,k){
|
||||||
user.ops[k] = _.partialRight(op, function(err, req){
|
user.ops[k] = _.partialRight(op, function(err, req){
|
||||||
//if (err) return Notification.text(err); // FIXME Circular dependency found: Notification <- User
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
//Notification.text(err.code ? err.message : err); // FIXME Circular dependency found: Notification <- User
|
||||||
alert(err.code ? err.message : err);
|
alert(err.code ? err.message : err);
|
||||||
// In the case of 200s, they're friendly alert messages like "You're pet has hatched!" - still send the op
|
// In the case of 200s, they're friendly alert messages like "You're pet has hatched!" - still send the op
|
||||||
if ((err.code && err.code >= 400) || !err.code) return;
|
if ((err.code && err.code >= 400) || !err.code) return;
|
||||||
|
|||||||
@@ -460,17 +460,17 @@ api.cast = function(req, res) {
|
|||||||
_.each(shared.wrap({}).ops, function(op,k){
|
_.each(shared.wrap({}).ops, function(op,k){
|
||||||
if (!api[k]) {
|
if (!api[k]) {
|
||||||
api[k] = function(req, res, next) {
|
api[k] = function(req, res, next) {
|
||||||
var user = res.locals.user;
|
res.locals.user.ops[k](req,function(err){
|
||||||
async.series([
|
// If we want to send something other than 500, pass err as {code: 200, message: "Not enough GP"}
|
||||||
function(cb){ user.ops[k](req, cb) },
|
|
||||||
function(cb){ user.save(cb) },
|
|
||||||
], function(err){
|
|
||||||
if (err) {
|
if (err) {
|
||||||
// If we want to send something other than 500, pass err as {code: 200, message: "Not enough GP"}
|
if (!err.code) return res.json(500,{err:err});
|
||||||
if (err.code) return res.json(err.code, err.message);
|
if (err.code >= 400) return res.json(err.code,{err:err.message});
|
||||||
return res.json(500,{err:err});
|
// In the case of 200s, they're friendly alert messages like "You're pet has hatched!" - still send the op
|
||||||
}
|
}
|
||||||
return res.send(200);
|
res.locals.user.save(function(err){
|
||||||
|
if (err) return res.json(500,{err:err});
|
||||||
|
res.send(200);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user