Skip to content

Commit

Permalink
Merge branch 'main' into headers-confirm-call
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored May 20, 2024
2 parents 2f8dc4e + 9d259c2 commit 5935d4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ let make = (~sessionId, ~publishableKey, ~clientSecret, ~endpoint) => {
if (
paymentMethodsResponseSent && customerPaymentMethodsResponseSent && sessionTokensResponseSent
) {
handlePostMessage([("preMountLoaderIframeUnMount", true->JSON.Encode.bool)])
Window.removeEventListener("message", handle)
}
None
Expand Down
9 changes: 9 additions & 0 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,21 @@ let make = (

let preMountLoaderIframeDiv = mountPreMountLoaderIframe()

let unMountPreMountLoaderIframe = () => {
switch preMountLoaderIframeDiv->Nullable.toOption {
| Some(iframe) => iframe->remove
| None => ()
}
}

let preMountLoaderMountedPromise = Promise.make((resolve, _reject) => {
let preMountLoaderIframeCallback = (ev: Types.event) => {
let json = ev.data->Identity.anyTypeToJson
let dict = json->getDictFromJson
if dict->Dict.get("preMountLoaderIframeMountedCallback")->Option.isSome {
resolve(true->JSON.Encode.bool)
} else if dict->Dict.get("preMountLoaderIframeUnMount")->Option.isSome {
unMountPreMountLoaderIframe()
}
}
addSmartEventListener(
Expand Down

0 comments on commit 5935d4b

Please sign in to comment.