UNPKG

@100mslive/react-native-room-kit

Version:

100ms Room Kit provides simple & easy to use UI components to build Live Streaming & Video Conferencing experiences in your apps.

64 lines 2.46 kB
import ActionTypes, { HmsStateActionTypes } from '../actionTypes'; const INITIAL_STATE = { userName: '', userId: undefined, endPoints: undefined, debugMode: false, hmsInstance: undefined, roomID: undefined, roomCode: undefined, token: undefined, isHLSFlow: true, roles: [], hmsSessionStore: null, spotlightTrackId: null, iosBuildConfig: null, onLeave: undefined }; const userReducer = (state = INITIAL_STATE, action) => { var _action$payload$optio, _action$payload$optio2, _action$payload$optio3, _action$payload$optio4, _action$payload$optio5; switch (action.type) { case ActionTypes.SAVE_USER_DATA.REQUEST: return { ...state, ...action.payload }; case ActionTypes.SET_HMS_INSTANCE: return { ...state, hmsInstance: action.payload.hmsInstance }; case ActionTypes.CLEAR_HMS_INSTANCE: return { ...state, hmsInstance: undefined, hmsSessionStore: null, spotlightTrackId: null }; case HmsStateActionTypes.SET_USER_NAME: return { ...state, userName: action.payload.userName }; case HmsStateActionTypes.SET_PREBUILT_DATA: state.roomCode = action.payload.roomCode; state.token = action.payload.token; state.userName = ((_action$payload$optio = action.payload.options) === null || _action$payload$optio === void 0 ? void 0 : _action$payload$optio.userName) ?? ''; state.userId = (_action$payload$optio2 = action.payload.options) === null || _action$payload$optio2 === void 0 ? void 0 : _action$payload$optio2.userId; state.endPoints = (_action$payload$optio3 = action.payload.options) === null || _action$payload$optio3 === void 0 ? void 0 : _action$payload$optio3.endPoints; state.debugMode = ((_action$payload$optio4 = action.payload.options) === null || _action$payload$optio4 === void 0 ? void 0 : _action$payload$optio4.debugMode) ?? false; state.iosBuildConfig = ((_action$payload$optio5 = action.payload.options) === null || _action$payload$optio5 === void 0 ? void 0 : _action$payload$optio5.ios) ?? null; return state; case HmsStateActionTypes.SET_ON_LEAVE_HANDLER: return { ...state, onLeave: action.payload.onLeave }; case HmsStateActionTypes.CLEAR_STATES: return INITIAL_STATE; default: return state; } }; export default userReducer; //# sourceMappingURL=userState.js.map