File size: 687 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { useEffect } from 'react';
import { useDispatch } from 'calypso/state';
import { fetchAllPlugins } from 'calypso/state/plugins/installed/actions';
import { isRequestingForAllSites } from 'calypso/state/plugins/installed/selectors';
import type { CalypsoDispatch } from 'calypso/state/types';
import type { AppState } from 'calypso/types';

const request = () => ( dispatch: CalypsoDispatch, getState: AppState ) => {
	if ( ! isRequestingForAllSites( getState() ) ) {
		dispatch( fetchAllPlugins() );
	}
};

export default function QueryAllJetpackSitesPlugins() {
	const dispatch = useDispatch();

	useEffect( () => {
		dispatch( request() );
	}, [ dispatch ] );

	return null;
}