Skip to content

Commit 653c56a

Browse files
committed
Update CardPresentPaymentsOnboardingUseCase to use "networkActivated" and refresh from SystemStatus too
1 parent 7cb62da commit 653c56a

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Networking/Networking/Mapper/SystemStatusMapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct SystemStatusMapper: Mapper {
2121

2222
/// For now, we're going to override the networkActivated Bool in each plugin to convey active or inactive -- in order to
2323
/// avoid a core data change to add a Bool for activated
24-
/// This will be undone in #xxxx
24+
/// This will be undone in #5269
2525
let activePlugins = systemStatus.activePlugins.map {
2626
$0.overrideNetworkActivated(isNetworkActivated: true)
2727
}

Networking/NetworkingTests/Mapper/SystemStatusMapperTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SystemStatusMapperTests: XCTestCase {
2222
let expectedAuthorName = "Automattic"
2323
let expectedAuthorUrl = "https://woocommerce.com"
2424
/// TODO - The mapper is overriding networkActivated to be true for active plugins in general
25-
/// When we fix #xxxx this test will need to be updated to properly test the
25+
/// When we fix #5269 this test will need to be updated to properly test the
2626
/// new `activated` attribute that will be added to SystemPlugin instead
2727
let expectedNetworkActivated = true
2828

@@ -58,7 +58,7 @@ class SystemStatusMapperTests: XCTestCase {
5858
let expectedAuthorName = "Matt Mullenweg"
5959
let expectedAuthorUrl = "http://ma.tt/"
6060
/// TODO - The mapper is overriding networkActivated to be true for active plugins in general
61-
/// When we fix #xxxx this test will need to be updated to properly test the
61+
/// When we fix #5269 this test will need to be updated to properly test the
6262
/// new `activated` attribute that will be added to SystemPlugin instead
6363
let expectedNetworkActivated = false
6464

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ private extension CardPresentPaymentsOnboardingUseCase {
5959
stores.dispatch(settingsAction)
6060

6161
// We need to sync plugins to check if WCPay is installed, up to date, and active
62-
let sitePluginsAction = SitePluginAction.synchronizeSitePlugins(siteID: siteID) { result in
62+
let systemPluginsAction = SystemStatusAction.synchronizeSystemPlugins(siteID: siteID) { result in
6363
if case let .failure(error) = result {
64-
DDLogError("[CardPresentPaymentsOnboarding] Error syncing site plugins: \(error)")
64+
DDLogError("[CardPresentPaymentsOnboarding] Error syncing system plugins: \(error)")
6565
errors.append(error)
6666
}
6767
group.leave()
6868
}
6969
group.enter()
70-
stores.dispatch(sitePluginsAction)
70+
stores.dispatch(systemPluginsAction)
7171

7272
// We need to sync payment gateway accounts to see if WCPay is set up correctly
7373
let paymentGatewayAccountsAction = PaymentGatewayAccountAction.loadAccounts(siteID: siteID) { result in
@@ -175,8 +175,10 @@ private extension CardPresentPaymentsOnboardingUseCase {
175175
}
176176

177177
func isWCPayActivated(plugin: SystemPlugin) -> Bool {
178-
// TODO hook up active/not if possible (might need to add to entity)
179-
return true
178+
// For now we are overriding networkActivated in SystemStatusMapper
179+
// to convey active / not active for a plugin.
180+
// TODO - replace with simply `activated` as part of #5269
181+
return plugin.networkActivated
180182
}
181183

182184
func getWCPayAccount() -> PaymentGatewayAccount? {

0 commit comments

Comments
 (0)