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
|
|
|
|
2018-02-07 13:34:40 +00:00
|
|
|
ReducerRegistry.register(
|
|
|
|
'features/background',
|
2018-02-14 18:28:22 +00:00
|
|
|
(state = DEFAULT_STATE, action) => {
|
2018-02-07 13:34:40 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case _SET_APP_STATE_LISTENER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
appStateListener: action.listener
|
|
|
|
};
|
2017-02-08 11:37:52 +00:00
|
|
|
|
2018-02-07 13:34:40 +00:00
|
|
|
case APP_STATE_CHANGED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
appState: action.appState
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|