Files
jitsi-meet/react/features/base/conference/reducer.js
Lyubomir Marinov d55e0f70d9 Import jitsi/jitsi-meet-react#2f23d98
As an intermediate step on the path to merging jitsi-meet and
jitsi-meet-react, import the whole source code of jitsi-meet-react as it
stands at
2f23d98424
i.e. the lastest master at the time of this import. No modifications are
applied to the imported source code in order to preserve a complete
snapshot of it in the repository of jitsi-meet and, thus, facilitate
comparison later on. Consequently, the source code of jitsi-meet and/or
jitsi-meet-react may not work. For example, jitsi-meet's jshint may be
unable to parse jitsi-meet-react's source code.
2016-10-12 10:31:52 -05:00

81 lines
2.2 KiB
JavaScript

import { ReducerRegistry } from '../redux';
import {
CONFERENCE_JOINED,
CONFERENCE_LEFT,
CONFERENCE_WILL_LEAVE,
SET_ROOM
} from './actionTypes';
import { isRoomValid } from './functions';
const INITIAL_STATE = {
jitsiConference: null,
/**
* Instance of JitsiConference that is currently in 'leaving' state.
*/
leavingJitsiConference: null,
/**
* The name of the room of the conference (to be) joined (i.e.
* {@link #jitsiConference}).
*
* @type {string}
*/
room: null
};
/**
* Listen for actions that contain the conference object, so that it can be
* stored for use by other action creators.
*/
ReducerRegistry.register('features/base/conference',
(state = INITIAL_STATE, action) => {
switch (action.type) {
case CONFERENCE_JOINED:
return {
...state,
jitsiConference: action.conference.jitsiConference
};
case CONFERENCE_LEFT:
if (state.jitsiConference === action.conference.jitsiConference) {
return {
...state,
jitsiConference: null,
leavingJitsiConference: state.leavingJitsiConference
=== action.conference.jitsiConference
? null
: state.leavingJitsiConference
};
}
break;
case CONFERENCE_WILL_LEAVE:
return {
...state,
leavingJitsiConference: action.conference.jitsiConference
};
case SET_ROOM: {
let room = action.room;
// Technically, there're multiple values which don't represent
// valid room names. Practically, each of them is as bad as the rest
// of them because we can't use any of them to join a conference.
if (!isRoomValid(room)) {
room = INITIAL_STATE.room;
}
if (state.room !== room) {
return {
...state,
room
};
}
break;
}
}
return state;
});