diff --git a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js index 59172ac6457..53f821c28c1 100644 --- a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js +++ b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js @@ -42,7 +42,7 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig self.wishlistProductIDs = JSON.parse(res); }); - return $.when(def, wishDef); + return Promise.all([def, wishDef]); }, /** * Updates the wishlist view (navbar) & the wishlist button (product page). @@ -95,7 +95,7 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig false ); - productReady.done(function (productId) { + productReady.then(function (productId) { productId = parseInt(productId, 10); if (productId && !_.contains(self.wishlistProductIDs, productId)) { @@ -108,11 +108,11 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig self.wishlistProductIDs.push(productId); self._updateWishlistView(); wSaleUtils.animateClone($('#my_wish'), $el.closest('form'), 25, 40); - }).fail(function () { + }).guardedCatch(function () { $el.prop("disabled", false).removeClass('disabled'); }); } - }).fail(function () { + }).guardedCatch(function () { $el.prop("disabled", false).removeClass('disabled'); }); }, @@ -138,16 +138,17 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig this._rpc({ route: '/shop/wishlist/remove/' + wish, - }).done(function () { + }).then(function () { $(tr).hide(); }); this.wishlistProductIDs = _.without(this.wishlistProductIDs, product); if (this.wishlistProductIDs.length === 0) { - deferred_redirect = deferred_redirect ? deferred_redirect : $.Deferred(); - deferred_redirect.then(function () { - self._redirectNoWish(); - }); + if (deferred_redirect) { + deferred_redirect.then(function () { + self._redirectNoWish(); + }); + } } this._updateWishlistView(); },