Skip to content

Commit

Permalink
fix: make code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
laurelfulford committed Aug 27, 2024
1 parent 6461db9 commit 38b6d13
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/modal-checkout/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,9 @@ domReady( () => {
const hasNewsletterPopup = document?.querySelector( '.newspack-newsletters-signup-modal' );

// We want to block closing the modal if redirecting elsewhere:
let shouldCloseModal = true;

if (
afterSuccessUrlInput &&
afterSuccessBehaviorInput &&
container?.checkoutComplete &&
! hasNewsletterPopup
) {
shouldCloseModal = false;
}
const shouldCloseModal = ! afterSuccessUrlInput || ! afterSuccessBehaviorInput || ! container?.checkoutComplete;

if ( shouldCloseModal ) {
if ( shouldCloseModal || hasNewsletterPopup ) {
spinner.style.display = 'flex';
if ( iframe && modalContent.contains( iframe ) ) {
// Reset iframe and modal content heights.
Expand Down Expand Up @@ -112,7 +103,7 @@ domReady( () => {
if ( window?.newspackReaderActivation?.openNewslettersSignupModal ) {
window.newspackReaderActivation.openNewslettersSignupModal( {
callback: handleCheckoutComplete,
skipClose: ( afterSuccessUrlInput && afterSuccessBehaviorInput ) ? true : false,
closeOnSuccess: shouldCloseModal,
} );
} else {
handleCheckoutComplete();
Expand Down

0 comments on commit 38b6d13

Please sign in to comment.