File size: 614 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { useContext } from 'react';
import { useCorePluginsQuery } from 'calypso/data/plugins/use-core-plugins-query';
import { PluginUpdateManagerContext } from '../context';

export function useSiteHasEligiblePlugins( siteSlug?: string ) {
	const { siteSlug: contextSiteSlug } = useContext( PluginUpdateManagerContext );
	const slug = siteSlug || contextSiteSlug;
	const { data: plugins = [], isFetched: isPluginsFetched } = useCorePluginsQuery(
		slug,
		true,
		true
	);
	const siteHasEligiblePlugins = isPluginsFetched && plugins.length > 0;
	return { siteHasEligiblePlugins, loading: ! isPluginsFetched };
}