@@ -43,14 +43,16 @@ public class AccountStore: Store {
4343 switch action {
4444 case . loadAccount( let userID, let onCompletion) :
4545 loadAccount ( userID: userID, onCompletion: onCompletion)
46- case . loadAndSynchronizeSiteIfNeeded( let siteID, let onCompletion) :
47- loadAndSynchronizeSiteIfNeeded ( siteID: siteID, onCompletion: onCompletion)
46+ case . loadAndSynchronizeSiteIfNeeded( let siteID, let isJetpackConnectionPackageSupported , let onCompletion) :
47+ loadAndSynchronizeSiteIfNeeded ( siteID: siteID, isJetpackConnectionPackageSupported : isJetpackConnectionPackageSupported , onCompletion: onCompletion)
4848 case . synchronizeAccount( let onCompletion) :
4949 synchronizeAccount ( onCompletion: onCompletion)
5050 case . synchronizeAccountSettings( let userID, let onCompletion) :
5151 synchronizeAccountSettings ( userID: userID, onCompletion: onCompletion)
52- case . synchronizeSites( let selectedSiteID, let onCompletion) :
53- synchronizeSites ( selectedSiteID: selectedSiteID, onCompletion: onCompletion)
52+ case . synchronizeSites( let selectedSiteID, let isJetpackConnectionPackageSupported, let onCompletion) :
53+ synchronizeSites ( selectedSiteID: selectedSiteID,
54+ isJetpackConnectionPackageSupported: isJetpackConnectionPackageSupported,
55+ onCompletion: onCompletion)
5456 case . synchronizeSitePlan( let siteID, let onCompletion) :
5557 synchronizeSitePlan ( siteID: siteID, onCompletion: onCompletion)
5658 case . updateAccountSettings( let userID, let tracksOptOut, let onCompletion) :
@@ -92,11 +94,11 @@ private extension AccountStore {
9294
9395 /// Returns the site if it exists in storage already. Otherwise, it synchronizes the WordPress.com sites and returns the site if it exists.
9496 ///
95- func loadAndSynchronizeSiteIfNeeded( siteID: Int64 , onCompletion: @escaping ( Result < Site , Error > ) -> Void ) {
97+ func loadAndSynchronizeSiteIfNeeded( siteID: Int64 , isJetpackConnectionPackageSupported : Bool , onCompletion: @escaping ( Result < Site , Error > ) -> Void ) {
9698 if let site = storageManager. viewStorage. loadSite ( siteID: siteID) ? . toReadOnly ( ) {
9799 onCompletion ( . success( site) )
98100 } else {
99- synchronizeSites ( selectedSiteID: siteID) { [ weak self] result in
101+ synchronizeSites ( selectedSiteID: siteID, isJetpackConnectionPackageSupported : isJetpackConnectionPackageSupported ) { [ weak self] result in
100102 guard let self = self else { return }
101103 guard let site = self . storageManager. viewStorage. loadSite ( siteID: siteID) ? . toReadOnly ( ) else {
102104 return onCompletion ( . failure( SynchronizeSiteError . unknownSite) )
@@ -108,7 +110,7 @@ private extension AccountStore {
108110
109111 /// Synchronizes the WordPress.com sites associated with the Network's Auth Token.
110112 ///
111- func synchronizeSites( selectedSiteID: Int64 ? , onCompletion: @escaping ( Result < Void , Error > ) -> Void ) {
113+ func synchronizeSites( selectedSiteID: Int64 ? , isJetpackConnectionPackageSupported : Bool , onCompletion: @escaping ( Result < Void , Error > ) -> Void ) {
112114 remote. loadSites ( )
113115 . flatMap { result -> AnyPublisher < Result < [ Site ] , Error > , Never > in
114116 switch result {
@@ -124,7 +126,7 @@ private extension AccountStore {
124126 // As a workaround, we need to make 2 other API requests (ref p91TBi-6lK-p2):
125127 // - Check if WooCommerce plugin is active via `wc/v3/settings` endpoint
126128 // - Fetch site metadata like the site name, description, and URL via `wp/v2/settings` endpoint
127- if site. isJetpackCPConnected {
129+ if site. isJetpackCPConnected, isJetpackConnectionPackageSupported {
128130 let wcAvailabilityPublisher = self . remote. checkIfWooCommerceIsActive ( for: site. siteID)
129131 let wpSiteSettingsPublisher = self . remote. fetchWordPressSiteSettings ( for: site. siteID)
130132 return Publishers . Zip3 ( sitePublisher, wcAvailabilityPublisher, wpSiteSettingsPublisher)
0 commit comments