Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ public struct JetpackConnectionProvisionResponse: Decodable {
public let userId: Int64
public let scope: String
public let secret: String

/// periphery: ignore - used in test module
public init(userId: Int64, scope: String, secret: String) {
self.userId = userId
self.scope = scope
self.secret = secret
}
Comment on lines +23 to +27
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 rely on the synthesized initializer in this case? Looks like the manual init does the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to explicitly add this initializer as I need it in JetpackSetupViewModelTests on the UI layer. The initializer needs to be public to be accessed from outside of the Networking module.

}
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

23.1
-----
- [*] Jetpack setup: Native experience for the connection step [https://github.com/woocommerce/woocommerce-ios/pull/15983]
- [*] Payments: Updated the In-Person Payments `Learn More` redirection to display the correct page based on the selected payment provider [https://github.com/woocommerce/woocommerce-ios/pull/15998]

23.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ final class LoginJetpackSetupCoordinator: Coordinator {
//
private extension LoginJetpackSetupCoordinator {
func showSetupSteps() {
let setupUI = JetpackSetupHostingController(siteURL: siteURL, connectionOnly: connectionOnly, onStoreNavigation: { [weak self] connectedEmail in
let setupUI = JetpackSetupHostingController(
siteURL: siteURL,
connectionOnly: connectionOnly,
wpcomCredentials: stores.sessionManager.defaultCredentials,
onStoreNavigation: { [weak self] connectedEmail in
guard let self, let email = connectedEmail else { return }
if email != self.stores.sessionManager.defaultAccount?.email {
// if the user authorized Jetpack with a different account, support them to log in with that account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ import protocol WooFoundation.Analytics
final class JetpackSetupHostingController: UIHostingController<JetpackSetupView> {
private let viewModel: JetpackSetupViewModel
private let authentication: Authentication
private let connectionWebViewCredentials: Credentials?
private let wpcomCredentials: Credentials?

init(siteURL: String,
connectionOnly: Bool,
connectionWebViewCredentials: Credentials? = nil,
wpcomCredentials: Credentials?,
stores: StoresManager = ServiceLocator.stores,
authentication: Authentication = ServiceLocator.authenticationManager,
analytics: Analytics = ServiceLocator.analytics,
onStoreNavigation: @escaping (String?) -> Void) {
self.viewModel = JetpackSetupViewModel(siteURL: siteURL,
connectionOnly: connectionOnly,
wpcomCredentials: wpcomCredentials,
stores: stores,
analytics: analytics,
onStoreNavigation: onStoreNavigation)
self.authentication = authentication
self.connectionWebViewCredentials = connectionWebViewCredentials
self.wpcomCredentials = wpcomCredentials
super.init(rootView: JetpackSetupView(viewModel: viewModel))

rootView.webViewPresentationHandler = { [weak self] in
Expand Down Expand Up @@ -92,7 +93,7 @@ final class JetpackSetupHostingController: UIHostingController<JetpackSetupView>
guard let self else { return }
self.viewModel.jetpackConnectionInterrupted = true
})
let webView = AuthenticatedWebViewController(viewModel: webViewModel, extraCredentials: connectionWebViewCredentials)
let webView = AuthenticatedWebViewController(viewModel: webViewModel, extraCredentials: wpcomCredentials)
webView.navigationItem.leftBarButtonItem = UIBarButtonItem(title: Localization.cancel,
style: .plain,
target: self,
Expand Down Expand Up @@ -327,10 +328,3 @@ private extension JetpackSetupView {
static let interruptedConnectionActionHandlerDelayTime: Double = 0.3
}
}

struct JetpackSetupView_Previews: PreviewProvider {
static var previews: some View {
JetpackSetupView(viewModel: JetpackSetupViewModel(siteURL: "https://test.com", connectionOnly: true))
JetpackSetupView(viewModel: JetpackSetupViewModel(siteURL: "https://test.com", connectionOnly: false))
}
}
Loading