-
Notifications
You must be signed in to change notification settings - Fork 11
Site address discovery #666
Conversation
…ith creator closure
…racking accordingly
selanthiraiyan
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL this 🙇
WordPressAuthenticator/Authenticator/WordPressAuthenticatorDelegateProtocol.swift
Show resolved
Hide resolved
| // 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() | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
Merging since wordpress-mobile/WordPress-iOS#19209 tests passed |
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
WordPressSiteInfoto 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.