PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.9.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.9.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Admin / package / preload / store / reducer.js

reducer.js in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.9.0, at src/Performance/Admin/package/preload/store/reducer.js

50 lines 913 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Internal dependencies
3 */
4 import { SET_PRELOAD_STATUS, PRELOADER_START, PRELOADER_CANCEL } from './actions';
5 import { PreloadId } from '../preload-id';
6
7 const DEFAULT_STATE = {
8 isPreloading: false,
9 cacheCount: 0,
10 progressPercent: 0,
11 source: '',
12 preloadId: '',
13 notice: {
14 type: '',
15 code: '',
16 message: '',
17 },
18 };
19
20 const reducer = ( state = DEFAULT_STATE, action ) => {
21 switch (action.type) {
22 case SET_PRELOAD_STATUS:
23 // Clear the preload ID while preloading, so the final notice can be sent.
24 if (action.newState.isPreloading) {
25 PreloadId.clear();
26 }
27
28 return {
29 ...state,
30 ...action.newState,
31 };
32 case PRELOADER_START:
33 return {
34 ...state,
35 isPreloading: true,
36 notice: action.notice,
37 };
38 case PRELOADER_CANCEL:
39 return {
40 ...state,
41 isPreloading: false,
42 notice: action.notice,
43 };
44 default:
45 return state;
46 }
47 };
48
49 export default reducer;
50