From f9d973cd19a54d73dfcbc664f9ec093ecefd3798 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Thu, 11 Jul 2024 15:29:46 +0530 Subject: [PATCH] fix: premount loader fix (#492) --- src/Payments/PreMountLoader.res | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Payments/PreMountLoader.res b/src/Payments/PreMountLoader.res index 305ebb686..b35d5f5a7 100644 --- a/src/Payments/PreMountLoader.res +++ b/src/Payments/PreMountLoader.res @@ -137,15 +137,26 @@ let make = ( }) React.useEffect4(() => { - if ( - paymentMethodsResponseSent && - customerPaymentMethodsResponseSent && - sessionTokensResponseSent && - savedPaymentMethodsResponseSent - ) { + let handleUnmount = () => { handlePostMessage([("preMountLoaderIframeUnMount", true->JSON.Encode.bool)]) Window.removeEventListener("message", handle) } + + switch hyperComponentName { + | Elements => + if ( + paymentMethodsResponseSent && + customerPaymentMethodsResponseSent && + sessionTokensResponseSent + ) { + handleUnmount() + } + | PaymentMethodsManagementElements => + if savedPaymentMethodsResponseSent { + handleUnmount() + } + } + None }, ( paymentMethodsResponseSent,