Skip to content

Commit

Permalink
Show loading spinner only on initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
josemiguel-alvarez committed Oct 23, 2023
1 parent ee076fb commit 3324974
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
5 changes: 0 additions & 5 deletions Sources/ShopifyCheckout/CheckoutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import UIKit
import WebKit

protocol CheckoutViewDelegate: AnyObject {
func checkoutViewDidStartNavigation()
func checkoutViewDidCompleteCheckout()
func checkoutViewDidFinishNavigation()
func checkoutViewDidClickLink(url: URL)
Expand Down Expand Up @@ -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()
}
Expand Down
9 changes: 1 addition & 8 deletions Sources/ShopifyCheckout/CheckoutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -130,13 +130,6 @@ class CheckoutViewController: UIViewController, UIAdaptivePresentationController
}

extension CheckoutViewController: CheckoutViewDelegate {

func checkoutViewDidStartNavigation() {
if initialNavigation {
spinner.startAnimating()
}
}

func checkoutViewDidFinishNavigation() {
spinner.stopAnimating()
initialNavigation = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ class MockCheckoutViewDelegate: CheckoutViewDelegate {

var didFailWithErrorExpectation: XCTestExpectation?

func checkoutViewDidStartNavigation() {
didStartNavigationExpectation?.fulfill()
}

func checkoutViewDidCompleteCheckout() {
didCompleteCheckoutExpectation?.fulfill()
}
Expand Down

0 comments on commit 3324974

Please sign in to comment.