diff options
Diffstat (limited to 'plugins/jetpack/jetpack_vendor/automattic/jetpack-search/src/dashboard/components/global-notices/store/reducer.js')
-rw-r--r-- | plugins/jetpack/jetpack_vendor/automattic/jetpack-search/src/dashboard/components/global-notices/store/reducer.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-search/src/dashboard/components/global-notices/store/reducer.js b/plugins/jetpack/jetpack_vendor/automattic/jetpack-search/src/dashboard/components/global-notices/store/reducer.js new file mode 100644 index 00000000..e0749197 --- /dev/null +++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-search/src/dashboard/components/global-notices/store/reducer.js @@ -0,0 +1,22 @@ +/** + * Internal dependencies + */ +import { CREATE_NOTICE, REMOVE_NOTICE } from './actions'; + +const notices = ( state = { notices: [] }, action ) => { + switch ( action.type ) { + case CREATE_NOTICE: + return { + ...state, + notices: [ ...state.notices, action.notice ], + }; + case REMOVE_NOTICE: + return { + ...state, + notices: state.notices.filter( notice => notice.id !== action.notice.id ), + }; + } + return state; +}; + +export default notices; |