Files
jitsi-meet/react/features/mobile/background/reducer.ts
Calinteodor 27c62b3d78 sdk(react-native-sdk): error fixes (#13549)
* feat(mobile/background/react-native-sdk): replaced removeListener deprecated method and fixed some undefined errors
2023-07-12 17:28:30 +03:00

37 lines
858 B
TypeScript

import { NativeEventSubscription } from 'react-native';
import ReducerRegistry from '../../base/redux/ReducerRegistry';
import { APP_STATE_CHANGED, _SET_APP_STATE_SUBSCRIPTION } from './actionTypes';
export interface IBackgroundState {
appState: string;
subscription?: NativeEventSubscription;
}
/**
* The default/initial redux state of the feature background.
*/
const DEFAULT_STATE = {
appState: 'active'
};
ReducerRegistry.register<IBackgroundState>('features/background', (state = DEFAULT_STATE, action): IBackgroundState => {
switch (action.type) {
case _SET_APP_STATE_SUBSCRIPTION:
return {
...state,
subscription: action.subscription
};
case APP_STATE_CHANGED:
return {
...state,
appState: action.appState
};
}
return state;
});