[#1468] hatchingPotion purchasing fix. also some temp hacks to get the UI to update

This commit is contained in:
Tyler Renelle
2013-09-07 19:06:41 -04:00
parent 5cb8238b7c
commit 0ccdb48751

View File

@@ -18,12 +18,15 @@ habitrpg.controller("MarketCtrl", ['$rootScope', '$scope', 'User', 'API_URL', '$
var message = "Buy this " + (type == 'egg' ? 'egg' : 'hatching potion') + " with " + item.value + " of your " + gems + " Gems?" var message = "Buy this " + (type == 'egg' ? 'egg' : 'hatching potion') + " with " + item.value + " of your " + gems + " Gems?"
if(confirm(message)){ if(confirm(message)){
var toPush = type === 'egg' ? item : item.name; $http.post(API_URL + '/api/v1/market/buy?type=' + type, item)
$http.post(API_URL + '/api/v1/market/buy?type=' + type, toPush)
.success(function(data){ .success(function(data){
User.user.balance = data.balance; // don't know what's going on, but trying to work with the returned data (a) isn't updating the ui, (b) isnt'
store.push(toPush); // stickign between refreshes until a force-refresh is called (user._v--).
//$sc¡ope.items = data.items.eggs; // FIXME this isn't updating the UI User.user._v--;
User.log({});
//User.user.balance = data.balance;
store.push(type === 'egg' ? item : item.name);
//$scope.items = data.items.eggs; // FIXME this isn't updating the UI
}).error(function(data){ }).error(function(data){
alert(data); alert(data);
console.error(data); console.error(data);