From 3324974bfef71abcd9063b797113f47e628fcdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=C3=81lvarez?= Date: Mon, 23 Oct 2023 15:27:32 +0200 Subject: [PATCH] Show loading spinner only on initial load --- Sources/ShopifyCheckout/CheckoutView.swift | 5 ----- Sources/ShopifyCheckout/CheckoutViewController.swift | 9 +-------- .../Mocks/MockCheckoutViewDelegate.swift | 4 ---- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/Sources/ShopifyCheckout/CheckoutView.swift b/Sources/ShopifyCheckout/CheckoutView.swift index e17a153f..b15ac876 100644 --- a/Sources/ShopifyCheckout/CheckoutView.swift +++ b/Sources/ShopifyCheckout/CheckoutView.swift @@ -25,7 +25,6 @@ import UIKit import WebKit protocol CheckoutViewDelegate: AnyObject { - func checkoutViewDidStartNavigation() func checkoutViewDidCompleteCheckout() func checkoutViewDidFinishNavigation() func checkoutViewDidClickLink(url: URL) @@ -156,10 +155,6 @@ extension CheckoutView: WKNavigationDelegate { return .allow } - func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { - viewDelegate?.checkoutViewDidStartNavigation() - } - func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { viewDelegate?.checkoutViewDidFinishNavigation() } diff --git a/Sources/ShopifyCheckout/CheckoutViewController.swift b/Sources/ShopifyCheckout/CheckoutViewController.swift index 0f2b32ca..ddbaa203 100644 --- a/Sources/ShopifyCheckout/CheckoutViewController.swift +++ b/Sources/ShopifyCheckout/CheckoutViewController.swift @@ -111,8 +111,8 @@ class CheckoutViewController: UIViewController, UIAdaptivePresentationController checkoutView.load(checkout: checkoutURL) } else if checkoutView.isLoading && initialNavigation { checkoutView.alpha = 0 - spinner.startAnimating() } + spinner.startAnimating() } @IBAction internal func close() { @@ -130,13 +130,6 @@ class CheckoutViewController: UIViewController, UIAdaptivePresentationController } extension CheckoutViewController: CheckoutViewDelegate { - - func checkoutViewDidStartNavigation() { - if initialNavigation { - spinner.startAnimating() - } - } - func checkoutViewDidFinishNavigation() { spinner.stopAnimating() initialNavigation = false diff --git a/Tests/ShopifyCheckoutTests/Mocks/MockCheckoutViewDelegate.swift b/Tests/ShopifyCheckoutTests/Mocks/MockCheckoutViewDelegate.swift index 12da4a20..4a65e17d 100644 --- a/Tests/ShopifyCheckoutTests/Mocks/MockCheckoutViewDelegate.swift +++ b/Tests/ShopifyCheckoutTests/Mocks/MockCheckoutViewDelegate.swift @@ -37,10 +37,6 @@ class MockCheckoutViewDelegate: CheckoutViewDelegate { var didFailWithErrorExpectation: XCTestExpectation? - func checkoutViewDidStartNavigation() { - didStartNavigationExpectation?.fulfill() - } - func checkoutViewDidCompleteCheckout() { didCompleteCheckoutExpectation?.fulfill() }