appReducer.js 887 Bytes
'use strict';

import InitialState from './appInitialState';

const {
	SET_PLATFORM,
	SET_HOST,
	SET_SERVICE_HOST,
	SET_PRIVILEGE_ID,
	SET_USER_LEVEL,
    SET_CHANNEL,
} = require('../../constants/actionTypes').default;

const initialState = new InitialState;

export default function appReducer(state = initialState, action) {
    if (!(state instanceof InitialState)) return initialState.merge(state);

    switch (action.type) {
		case SET_PLATFORM:
			return state.set('platform', action.payload);
		case SET_HOST:
			return state.set('host', action.payload);
		case SET_SERVICE_HOST:
			return state.set('serviceHost', action.payload);
		case SET_PRIVILEGE_ID:
			return state.set('privilegeId', action.payload);
		case SET_USER_LEVEL:
			return state.set('userLevel', action.payload);
		case SET_CHANNEL:
			return state.set('channel', action.payload);	
    }

    return state;
}