jiti-meet/react/features/base/app/reducer.ts

35 lines
715 B
TypeScript
Raw Normal View History

import ReducerRegistry from '../redux/ReducerRegistry';
2017-06-09 19:09:23 +00:00
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
export interface IAppState {
app?: Object|undefined;
}
ReducerRegistry.register('features/base/app', (state: IAppState = {}, action) => {
switch (action.type) {
2017-06-09 19:09:23 +00:00
case APP_WILL_MOUNT: {
const { app } = action;
if (state.app !== app) {
return {
...state,
2017-06-09 19:09:23 +00:00
app
};
}
break;
2017-06-09 19:09:23 +00:00
}
case APP_WILL_UNMOUNT:
if (state.app === action.app) {
return {
...state,
2016-12-07 22:08:35 +00:00
app: undefined
};
}
break;
}
return state;
});