Skip to content

Commit

Permalink
Set useRef to false in SaleErrorView
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl committed Jun 27, 2024
1 parent b5b512b commit 7abb88b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function HandoverProvider({ children }: HandoverProviderProps) {
...prev,
[handoverId]: true,
}));

setTimeout(() => {
setHandoverBusy((prev) => ({
...prev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -188,7 +181,15 @@ export function PayWithCoins() {
{t('views.PAYMENT_METHODS.handover.success')}
</Heading>
),
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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function SaleErrorView({
blockExplorerLink,
errorType,
}: SaleErrorViewProps) {
const mounted = useRef(false);

const { t } = useTranslation();
const {
goBackToPaymentMethods,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7abb88b

Please sign in to comment.