@@ -2,6 +2,7 @@ import * as Sentry from '@sentry/electron/renderer';
22import { useState , useEffect , useRef , useMemo , useCallback } from 'react' ;
33import { z } from 'zod' ;
44import { useAuth } from 'src/hooks/use-auth' ;
5+ import { useFeatureFlags } from 'src/hooks/use-feature-flags' ;
56import { reconcileConnectedSites } from 'src/hooks/use-fetch-wpcom-sites/reconcile-connected-sites' ;
67import { useOffline } from 'src/hooks/use-offline' ;
78import { getIpcApi } from 'src/lib/get-ipc-api' ;
@@ -59,14 +60,18 @@ function hasSupportedPlan( site: SitesEndpointSite ): boolean {
5960 return site . plan ?. features . active . includes ( STUDIO_SYNC_FEATURE_NAME ) ?? false ;
6061}
6162
62- function getSyncSupport ( site : SitesEndpointSite , connectedSiteIds : number [ ] ) : SyncSupport {
63+ function getSyncSupport (
64+ site : SitesEndpointSite ,
65+ connectedSiteIds : number [ ] ,
66+ pressableSyncEnabled : boolean
67+ ) : SyncSupport {
6368 if ( site . is_deleted ) {
6469 return 'deleted' ;
6570 }
6671 if ( ! site . capabilities ?. manage_options ) {
6772 return 'missing-permissions' ;
6873 }
69- if ( site . hosting_provider_guess === 'pressable' ) {
74+ if ( pressableSyncEnabled && site . hosting_provider_guess === 'pressable' ) {
7075 return 'syncable' ;
7176 }
7277 if ( isJetpackSite ( site ) && ! hasSupportedPlan ( site ) ) {
@@ -102,7 +107,11 @@ export function transformSingleSiteResponse(
102107 } ;
103108}
104109
105- export function transformSitesResponse ( sites : unknown [ ] , connectedSiteIds : number [ ] ) : SyncSite [ ] {
110+ export function transformSitesResponse (
111+ sites : unknown [ ] ,
112+ connectedSiteIds : number [ ] ,
113+ pressableSyncEnabled : boolean
114+ ) : SyncSite [ ] {
106115 const validatedSites = sites . reduce < SitesEndpointSite [ ] > ( ( acc , rawSite ) => {
107116 try {
108117 const site = sitesEndpointSiteSchema . parse ( rawSite ) ;
@@ -123,7 +132,7 @@ export function transformSitesResponse( sites: unknown[], connectedSiteIds: numb
123132 // The API returns the wrong value for the `is_wpcom_staging_site` prop while staging sites
124133 // are being created. Hence the check in other sites' `wpcom_staging_blog_ids` arrays.
125134 const isStaging = allStagingSiteIds . includes ( site . ID ) ;
126- const syncSupport = getSyncSupport ( site , connectedSiteIds ) ;
135+ const syncSupport = getSyncSupport ( site , connectedSiteIds , pressableSyncEnabled ) ;
127136
128137 return transformSingleSiteResponse ( site , syncSupport , isStaging ) ;
129138 } ) ;
@@ -136,6 +145,7 @@ export const useFetchWpComSites = ( connectedSiteIdsOnlyForSelectedSite: number[
136145 const { isAuthenticated, client } = useAuth ( ) ;
137146 const isFetchingSites = useRef ( false ) ;
138147 const isOffline = useOffline ( ) ;
148+ const { pressableSyncEnabled } = useFeatureFlags ( ) ;
139149
140150 const joinedConnectedSiteIds = connectedSiteIdsOnlyForSelectedSite . join ( ',' ) ;
141151 // we need this trick to avoid unnecessary re-renders,
@@ -175,7 +185,8 @@ export const useFetchWpComSites = ( connectedSiteIdsOnlyForSelectedSite: number[
175185 const parsedResponse = sitesEndpointResponseSchema . parse ( response ) ;
176186 const syncSites = transformSitesResponse (
177187 parsedResponse . sites ,
178- allConnectedSites . map ( ( { id } ) => id )
188+ allConnectedSites . map ( ( { id } ) => id ) ,
189+ pressableSyncEnabled
179190 ) ;
180191
181192 // whenever array of syncSites changes, we need to update connectedSites to keep them updated with wordpress.com
@@ -212,15 +223,15 @@ export const useFetchWpComSites = ( connectedSiteIdsOnlyForSelectedSite: number[
212223 } finally {
213224 isFetchingSites . current = false ;
214225 }
215- } , [ client ?. req , isAuthenticated , isOffline ] ) ;
226+ } , [ client ?. req , isAuthenticated , isOffline , pressableSyncEnabled ] ) ;
216227
217228 useEffect ( ( ) => {
218229 fetchSites ( ) ;
219230 } , [ fetchSites ] ) ;
220231
221232 const syncSitesWithSyncSupportForSelectedSite = useMemo (
222- ( ) => transformSitesResponse ( rawSyncSites , memoizedConnectedSiteIds ) ,
223- [ rawSyncSites , memoizedConnectedSiteIds ]
233+ ( ) => transformSitesResponse ( rawSyncSites , memoizedConnectedSiteIds , pressableSyncEnabled ) ,
234+ [ rawSyncSites , memoizedConnectedSiteIds , pressableSyncEnabled ]
224235 ) ;
225236
226237 return {
0 commit comments