From 9020c9b797102e6bb2eb210a6f1a58f34fc1693c Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 27 Oct 2022 09:09:45 +0300 Subject: [PATCH] Use the same errorHandler Otherwise old messages may get stuck --- modules/ppcp-button/resources/js/button.js | 11 ++++++++--- .../js/modules/ContextBootstrap/CartBootstap.js | 5 +++-- .../js/modules/ContextBootstrap/CheckoutBootstap.js | 5 +++-- .../js/modules/ContextBootstrap/MiniCartBootstap.js | 5 +++-- .../js/modules/ContextBootstrap/PayNowBootstrap.js | 4 ++-- .../modules/ContextBootstrap/SingleProductBootstap.js | 5 +++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/ppcp-button/resources/js/button.js b/modules/ppcp-button/resources/js/button.js index b1f19bbac..0e3fae7b0 100644 --- a/modules/ppcp-button/resources/js/button.js +++ b/modules/ppcp-button/resources/js/button.js @@ -100,7 +100,8 @@ const bootstrap = () => { if (PayPalCommerceGateway.mini_cart_buttons_enabled === '1') { const miniCartBootstrap = new MiniCartBootstap( PayPalCommerceGateway, - renderer + renderer, + errorHandler, ); miniCartBootstrap.init(); @@ -112,6 +113,7 @@ const bootstrap = () => { PayPalCommerceGateway, renderer, messageRenderer, + errorHandler, ); singleProductBootstrap.init(); @@ -121,6 +123,7 @@ const bootstrap = () => { const cartBootstrap = new CartBootstrap( PayPalCommerceGateway, renderer, + errorHandler, ); cartBootstrap.init(); @@ -131,7 +134,8 @@ const bootstrap = () => { PayPalCommerceGateway, renderer, messageRenderer, - spinner + spinner, + errorHandler, ); checkoutBootstap.init(); @@ -142,7 +146,8 @@ const bootstrap = () => { PayPalCommerceGateway, renderer, messageRenderer, - spinner + spinner, + errorHandler, ); payNowBootstrap.init(); } diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CartBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CartBootstap.js index d32ca440f..3c5d14b9d 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CartBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CartBootstap.js @@ -2,9 +2,10 @@ import CartActionHandler from '../ActionHandler/CartActionHandler'; import ErrorHandler from '../ErrorHandler'; class CartBootstrap { - constructor(gateway, renderer) { + constructor(gateway, renderer, errorHandler) { this.gateway = gateway; this.renderer = renderer; + this.errorHandler = errorHandler; } init() { @@ -28,7 +29,7 @@ class CartBootstrap { render() { const actionHandler = new CartActionHandler( PayPalCommerceGateway, - new ErrorHandler(this.gateway.labels.error.generic), + this.errorHandler, ); this.renderer.render( diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js index b491bcb1e..a513e9c76 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js @@ -8,11 +8,12 @@ import { } from "../Helper/CheckoutMethodState"; class CheckoutBootstap { - constructor(gateway, renderer, messages, spinner) { + constructor(gateway, renderer, messages, spinner, errorHandler) { this.gateway = gateway; this.renderer = renderer; this.messages = messages; this.spinner = spinner; + this.errorHandler = errorHandler; this.standardOrderButtonSelector = ORDER_BUTTON_SELECTOR; } @@ -60,7 +61,7 @@ class CheckoutBootstap { } const actionHandler = new CheckoutActionHandler( PayPalCommerceGateway, - new ErrorHandler(this.gateway.labels.error.generic), + this.errorHandler, this.spinner ); diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js index 35465c12e..96e7abb8e 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js @@ -2,9 +2,10 @@ import ErrorHandler from '../ErrorHandler'; import CartActionHandler from '../ActionHandler/CartActionHandler'; class MiniCartBootstap { - constructor(gateway, renderer) { + constructor(gateway, renderer, errorHandler) { this.gateway = gateway; this.renderer = renderer; + this.errorHandler = errorHandler; this.actionHandler = null; } @@ -12,7 +13,7 @@ class MiniCartBootstap { this.actionHandler = new CartActionHandler( PayPalCommerceGateway, - new ErrorHandler(this.gateway.labels.error.generic), + this.errorHandler, ); this.render(); diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/PayNowBootstrap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/PayNowBootstrap.js index 4b2583c98..4d69532eb 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/PayNowBootstrap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/PayNowBootstrap.js @@ -2,8 +2,8 @@ import CheckoutBootstap from './CheckoutBootstap' import {isChangePaymentPage} from "../Helper/Subscriptions"; class PayNowBootstrap extends CheckoutBootstap { - constructor(gateway, renderer, messages, spinner) { - super(gateway, renderer, messages, spinner) + constructor(gateway, renderer, messages, spinner, errorHandler) { + super(gateway, renderer, messages, spinner, errorHandler) } updateUi() { diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js index ecb44eabe..d4634ce1f 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js @@ -3,10 +3,11 @@ import UpdateCart from "../Helper/UpdateCart"; import SingleProductActionHandler from "../ActionHandler/SingleProductActionHandler"; class SingleProductBootstap { - constructor(gateway, renderer, messages) { + constructor(gateway, renderer, messages, errorHandler) { this.gateway = gateway; this.renderer = renderer; this.messages = messages; + this.errorHandler = errorHandler; } @@ -81,7 +82,7 @@ class SingleProductBootstap { this.messages.hideMessages(); }, document.querySelector('form.cart'), - new ErrorHandler(this.gateway.labels.error.generic), + this.errorHandler, ); this.renderer.render(