2023-07-12 17:28:30 +03:00
|
|
|
import { NativeEventSubscription } from 'react-native';
|
2023-05-09 12:10:46 +03:00
|
|
|
|
2022-08-26 12:54:16 +03:00
|
|
|
import ReducerRegistry from '../../base/redux/ReducerRegistry';
|
2017-02-10 10:13:39 -06:00
|
|
|
|
2023-07-12 17:28:30 +03:00
|
|
|
import { APP_STATE_CHANGED, _SET_APP_STATE_SUBSCRIPTION } from './actionTypes';
|
2017-02-08 12:37:52 +01:00
|
|
|
|
2024-10-22 16:19:31 +03:00
|
|
|
export interface IMobileBackgroundState {
|
2022-08-26 12:54:16 +03:00
|
|
|
appState: string;
|
2023-07-12 17:28:30 +03:00
|
|
|
subscription?: NativeEventSubscription;
|
2022-08-26 12:54:16 +03:00
|
|
|
}
|
|
|
|
|
|
2018-02-14 12:28:22 -06:00
|
|
|
/**
|
|
|
|
|
* The default/initial redux state of the feature background.
|
|
|
|
|
*/
|
|
|
|
|
const DEFAULT_STATE = {
|
2024-10-22 16:19:31 +03:00
|
|
|
appState: ''
|
2018-02-07 14:34:40 +01:00
|
|
|
};
|
2017-02-08 12:37:52 +01:00
|
|
|
|
2024-10-22 16:19:31 +03:00
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
|
ReducerRegistry.register<IMobileBackgroundState>('features/mobile/background', (state = DEFAULT_STATE, action): IMobileBackgroundState => {
|
2019-07-31 14:47:52 +02:00
|
|
|
switch (action.type) {
|
2023-07-12 17:28:30 +03:00
|
|
|
|
|
|
|
|
case _SET_APP_STATE_SUBSCRIPTION:
|
2019-07-31 14:47:52 +02:00
|
|
|
return {
|
|
|
|
|
...state,
|
2023-07-12 17:28:30 +03:00
|
|
|
subscription: action.subscription
|
2019-07-31 14:47:52 +02:00
|
|
|
};
|
2017-02-08 12:37:52 +01:00
|
|
|
|
2019-07-31 14:47:52 +02:00
|
|
|
case APP_STATE_CHANGED:
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
appState: action.appState
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-02-07 14:34:40 +01:00
|
|
|
|
2019-07-31 14:47:52 +02:00
|
|
|
return state;
|
|
|
|
|
});
|