2018-02-14 18:28:22 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-03-27 09:39:10 +00:00
|
|
|
import { ReducerRegistry } from '../../base/redux';
|
2017-02-10 16:13:39 +00:00
|
|
|
|
2017-02-08 11:37:52 +00:00
|
|
|
import {
|
|
|
|
_SET_APP_STATE_LISTENER,
|
|
|
|
APP_STATE_CHANGED
|
|
|
|
} from './actionTypes';
|
|
|
|
|
2018-02-14 18:28:22 +00:00
|
|
|
/**
|
|
|
|
* The default/initial redux state of the feature background.
|
|
|
|
*/
|
|
|
|
const DEFAULT_STATE = {
|
2018-02-07 13:34:40 +00:00
|
|
|
appState: 'active'
|
|
|
|
};
|
2017-02-08 11:37:52 +00:00
|
|
|
|
2019-07-31 12:47:52 +00:00
|
|
|
ReducerRegistry.register('features/background', (state = DEFAULT_STATE, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case _SET_APP_STATE_LISTENER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
appStateListener: action.listener
|
|
|
|
};
|
2017-02-08 11:37:52 +00:00
|
|
|
|
2019-07-31 12:47:52 +00:00
|
|
|
case APP_STATE_CHANGED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
appState: action.appState
|
|
|
|
};
|
|
|
|
}
|
2018-02-07 13:34:40 +00:00
|
|
|
|
2019-07-31 12:47:52 +00:00
|
|
|
return state;
|
|
|
|
});
|