From 13e4411b89af84abe52c44d82e92c131ee9e9b82 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 4 May 2020 12:35:19 +0200 Subject: [PATCH] Add error message on cart populate failure and don't keep re-sending the data to the server. This was triggering many requests to be continuously re-sent in a very problematic way (server-melting), and with no user feedback. --- app/assets/javascripts/darkswarm/services/cart.js.coffee | 3 ++- config/locales/en.yml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/services/cart.js.coffee b/app/assets/javascripts/darkswarm/services/cart.js.coffee index d63351ba67..55f7f6da1a 100644 --- a/app/assets/javascripts/darkswarm/services/cart.js.coffee +++ b/app/assets/javascripts/darkswarm/services/cart.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $rootScope, $resource, localStorageService) -> +Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $rootScope, $resource, localStorageService, RailsFlashLoader) -> # Handles syncing of current cart/order state to server new class Cart dirty: false @@ -50,6 +50,7 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo @popQueue() if @update_enqueued .error (response, status)=> + RailsFlashLoader.loadFlash({error: t('js.cart.add_to_cart_failed')}) @update_running = false compareAndNotifyStockLevels: (stockLevels) => diff --git a/config/locales/en.yml b/config/locales/en.yml index e84c10c022..ad8802ae2b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2438,6 +2438,10 @@ See the %{link} to find out more about %{sitename}'s features and to start using resolve_errors: Please resolve the following errors more_items: "+ %{count} More" default_card_updated: Default Card Updated + cart: + add_to_cart_failed: > + There was a problem adding this product to the cart. + Perhaps it has become unavailable or the shop is closing. admin: enterprise_limit_reached: "You have reached the standard limit of enterprises per account. Write to %{contact_email} if you need to increase it." modals: