fixes for inconsistent cart state
This commit is contained in:
@@ -18,6 +18,7 @@ var states = {}
|
||||
var _itemsInCart = new ItemInCartCollection();
|
||||
var _itemsForDisplay = new ItemCollection();
|
||||
_itemsForDisplay.setFromCart(true);
|
||||
|
||||
var _deliveryDestination = new DeliveryDestination();
|
||||
var _deliveryDestinationErrors = {};
|
||||
var _deliveryCosts = new Place({
|
||||
@@ -26,10 +27,8 @@ var _deliveryCosts = new Place({
|
||||
|
||||
var _cartDataLoadCalled = false;
|
||||
|
||||
|
||||
var loadCart = function() {
|
||||
|
||||
states = {};
|
||||
_itemsInCart.fetch({
|
||||
success: function() {
|
||||
states = {}
|
||||
@@ -37,26 +36,22 @@ var loadCart = function() {
|
||||
var itemInCart = _itemsInCart.models[i];
|
||||
states[itemInCart.get('item_id')] = itemInCart;
|
||||
}
|
||||
CartActions.dataLoaded();
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
|
||||
_deliveryDestination.fetch({
|
||||
success: function() {
|
||||
validateDeliveryDestinationForm();
|
||||
fetchPlace();
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
|
||||
//_deliveryDestination.fetch({
|
||||
//success: function() {
|
||||
//validateDeliveryDestinationForm();
|
||||
//fetchPlace();
|
||||
//CartActions.dataLoaded();
|
||||
//}
|
||||
//});
|
||||
_cartDataLoadCalled = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -265,7 +260,6 @@ AppDispatcher.register(function(payload) {
|
||||
var text;
|
||||
|
||||
switch (action.actionType) {
|
||||
|
||||
case CartConstants.LOAD_CART_CONTENTS:
|
||||
loadCart();
|
||||
break;
|
||||
|
||||
@@ -34,7 +34,9 @@ var getItemIdFromUrl = function() {
|
||||
var itemIdRegex = /artikal\/(\d+)\//g;
|
||||
var match = itemIdRegex.exec(url);
|
||||
|
||||
return match[1];
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
};
|
||||
|
||||
var fetchItemWithDetails = function() {
|
||||
@@ -191,4 +193,4 @@ AppDispatcher.register(function(payload) {
|
||||
|
||||
});
|
||||
|
||||
module.exports = ItemStore;
|
||||
module.exports = ItemStore;
|
||||
|
||||
Reference in New Issue
Block a user