blob: 3c5272bc682bfb39642709e884398415ce7ae374 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { fetchJetpackSettings, fetchSearchPlanInfo } from './controls';
import { setJetpackSettings } from './actions/jetpack-settings';
import { setSearchPlanInfo } from './actions/site-plan';
import { errorNotice } from '../components/global-notices/store/actions';
/**
* Yield actions to get Search Module Status
*
* @yields {object} - an action object.
* @returns {object} - an action object.
*/
export function* getSearchModuleStatus() {
try {
const settings = yield fetchJetpackSettings();
if ( settings ) {
return setJetpackSettings( settings );
}
} catch ( e ) {
return errorNotice( __( 'Error fetching settings…', 'jetpack-search-pkg' ) );
}
}
/**
* Yield actions to get search plan info
*
* @yields {object} - an action object.
* @returns {object} - an action object.
*/
export function* getSearchPlanInfo() {
try {
const planInfo = yield fetchSearchPlanInfo();
if ( planInfo ) {
return setSearchPlanInfo( planInfo );
}
} catch ( e ) {
return errorNotice( __( 'Error fetching search plan…', 'jetpack-search-pkg' ) );
}
}
export default { getSearchModuleStatus, getSearchPlanInfo };
|