From 7abb88bd492ba51629848fbae15c1544b04c3f1d Mon Sep 17 00:00:00 2001 From: Mimi Immutable Date: Thu, 27 Jun 2024 16:15:09 +1000 Subject: [PATCH] Set useRef to false in SaleErrorView --- .../handover-context/HandoverProvider.tsx | 1 + .../src/widgets/sale/views/PayWithCoins.tsx | 17 +++++++++-------- .../src/widgets/sale/views/SaleErrorView.tsx | 11 ++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/checkout/widgets-lib/src/context/handover-context/HandoverProvider.tsx b/packages/checkout/widgets-lib/src/context/handover-context/HandoverProvider.tsx index 56c79317d1..4be4c771a3 100644 --- a/packages/checkout/widgets-lib/src/context/handover-context/HandoverProvider.tsx +++ b/packages/checkout/widgets-lib/src/context/handover-context/HandoverProvider.tsx @@ -80,6 +80,7 @@ export function HandoverProvider({ children }: HandoverProviderProps) { ...prev, [handoverId]: true, })); + setTimeout(() => { setHandoverBusy((prev) => ({ ...prev, diff --git a/packages/checkout/widgets-lib/src/widgets/sale/views/PayWithCoins.tsx b/packages/checkout/widgets-lib/src/widgets/sale/views/PayWithCoins.tsx index 954f2a67bc..ceff96814b 100644 --- a/packages/checkout/widgets-lib/src/widgets/sale/views/PayWithCoins.tsx +++ b/packages/checkout/widgets-lib/src/widgets/sale/views/PayWithCoins.tsx @@ -169,13 +169,6 @@ export function PayWithCoins() { if (executeResponse?.done) { const details = { transactionId: signResponse?.transactionId }; - sendSuccessEvent( - SaleWidgetViews.SALE_SUCCESS, - executeResponse?.transactions, - signTokenIds, - details, - ); // checkoutPrimarySaleSaleSuccess_SuccessEventSucceeded - addHandover({ duration: 2000, animationUrl: getRemoteRive( @@ -188,7 +181,15 @@ export function PayWithCoins() { {t('views.PAYMENT_METHODS.handover.success')} ), - onClose: () => sendCloseEvent(SaleWidgetViews.SALE_SUCCESS), // checkoutPrimarySaleSaleSuccess_CloseButtonPressed + onClose: () => { + sendSuccessEvent( + SaleWidgetViews.SALE_SUCCESS, + executeResponse?.transactions, + signTokenIds, + details, + ); // checkoutPrimarySaleSaleSuccess_SuccessEventSucceeded + sendCloseEvent(SaleWidgetViews.SALE_SUCCESS); // checkoutPrimarySaleSaleSuccess_CloseButtonPressed + }, }); } }, [executeResponse]); diff --git a/packages/checkout/widgets-lib/src/widgets/sale/views/SaleErrorView.tsx b/packages/checkout/widgets-lib/src/widgets/sale/views/SaleErrorView.tsx index 8597c15ade..16dc89aea8 100644 --- a/packages/checkout/widgets-lib/src/widgets/sale/views/SaleErrorView.tsx +++ b/packages/checkout/widgets-lib/src/widgets/sale/views/SaleErrorView.tsx @@ -46,6 +46,8 @@ export function SaleErrorView({ blockExplorerLink, errorType, }: SaleErrorViewProps) { + const mounted = useRef(false); + const { t } = useTranslation(); const { goBackToPaymentMethods, @@ -238,15 +240,10 @@ export function SaleErrorView({ }; }; - const isFirstRender = useRef(true); - useEffect(() => { - if (!environment || !currentErrorType) return; + if (!environment || !currentErrorType || mounted.current) return; - if (isFirstRender.current) { - isFirstRender.current = false; - return; - } + mounted.current = true; addHandover({ animationUrl: getRemoteRive(