Skip to content

Commit

Permalink
skip checking Calypso Stats connection status
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzj committed Oct 1, 2024
1 parent 00292b3 commit e194446
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/my-sites/stats/hooks/use-jetpack-connection-status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import config from '@automattic/calypso-config';
import { useQuery } from '@tanstack/react-query';
import wpcom from 'calypso/lib/wp';
import getDefaultQueryParams from './default-query-params';

const isOdysseyStats = config.isEnabled( 'is_running_in_jetpack_site' );

interface ConnectionInfo {
isRegistered: boolean;
isUserConnected: boolean;
Expand All @@ -21,7 +24,8 @@ export function useJetpackConnectionStatus( siteId: number | null, isSimpleSites
...getDefaultQueryParams< ConnectionInfo >(),
queryKey: [ 'stats', 'jetpack-connnection-status', siteId, isSimpleSites ],
queryFn: () => {
if ( ! isSimpleSites ) {
// Simple sites are always connected, and sites in Calypso are always fully connected too, so we skip those.
if ( ! isSimpleSites && isOdysseyStats ) {
return queryJetpackConnectionStatus();
}
return { isRegistered: true, isUserConnected: true };
Expand All @@ -30,6 +34,6 @@ export function useJetpackConnectionStatus( siteId: number | null, isSimpleSites
...data,
isSiteFullyConnected: data.isRegistered && data.isUserConnected,
} ),
staleTime: 1000 * 60 * 5, // 5 minutes
staleTime: 1000 * 60 * 1, // 1 minutes
} );
}

0 comments on commit e194446

Please sign in to comment.