Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Conversation

@itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Aug 16, 2022

Part of woocommerce/woocommerce-ios#7468

Description

This PR adds a new flow for troubleshooting a given site address. This flow reuses the current site address UI and returns the WordPressSiteInfo to a new delegate method for checking the problem of the site and show appropriate error message on the host app.

While testing the integration in woocommerce/woocommerce-ios#7484, I found that for a non-existent site, the check is taking quite long to return an error - the library was checking for WordPress while we could check for its existence first. This PR adds that with a 10-second timeout and displays the error inline.

This PR also updates analytics by tracking a new flow site_discovery.

Testing

Please check woocommerce/woocommerce-ios#7484 for testing steps.

@itsmeichigo itsmeichigo marked this pull request as ready for review August 17, 2022 08:06
@selanthiraiyan selanthiraiyan self-assigned this Aug 17, 2022
Copy link
Contributor

@selanthiraiyan selanthiraiyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me.
I have also tested the WCiOS PR, and it works as expected. 🎉

I left a nit and a question.

func instantiateViewController<T: NSObject>(ofClass classType: T.Type, creator: ((NSCoder) -> UIViewController?)? = nil) -> T? {
let identifier = classType.classNameWithoutNamespaces
return instance.instantiateViewController(withIdentifier: identifier) as? T
return instance.instantiateViewController(identifier: identifier, creator: creator) as? T
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL this 🙇

Comment on lines +442 to +468
// Checks that the site exists
var request = URLRequest(url: url)
request.httpMethod = "HEAD"
request.timeoutInterval = 10.0 // waits for 10 seconds
let task = URLSession.shared.dataTask(with: request) { [weak self] _, _, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }

if let error = error {
self.configureViewLoading(false)

if self.authenticationDelegate.shouldHandleError(error) {
self.authenticationDelegate.handleError(error) { customUI in
self.pushCustomUI(customUI)
}
return
}

return self.displayError(message: Localization.nonExistentSiteError, moveVoiceOverFocus: true)
}

// Proceeds to check for the site's WordPress
self.guessXMLRPCURL(for: self.loginFields.siteAddress)
}
}
task.resume()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Should we raise a PR in the WP iOS repository and test this change as this code will execute even if isSiteDiscovery is false? 🤔
Internal reference - p91TBi-49U-p2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Added a PR here: wordpress-mobile/WordPress-iOS#19209.

@itsmeichigo
Copy link
Contributor Author

Merging since wordpress-mobile/WordPress-iOS#19209 tests passed

@itsmeichigo itsmeichigo enabled auto-merge August 18, 2022 10:04
@itsmeichigo itsmeichigo merged commit dd98be2 into trunk Aug 18, 2022
@itsmeichigo itsmeichigo deleted the wcios/site-address-discovery branch August 18, 2022 10:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants