2022-08-26 09:54:16 +00:00
|
|
|
import ReducerRegistry from '../../base/redux/ReducerRegistry';
|
2017-02-10 16:13:39 +00:00
|
|
|
|
2017-02-08 11:37:52 +00:00
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
APP_STATE_CHANGED,
|
|
|
|
_SET_APP_STATE_LISTENER
|
2017-02-08 11:37:52 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
|
2022-08-26 09:54:16 +00:00
|
|
|
export interface IBackgroundState {
|
|
|
|
appState: string;
|
|
|
|
appStateListener?: Function;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IBackgroundState>('features/background', (state = DEFAULT_STATE, action): IBackgroundState => {
|
2019-07-31 12:47:52 +00:00
|
|
|
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;
|
|
|
|
});
|