| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 | 
							- import JitsiMeetJS from '../lib-jitsi-meet';
 - import {
 -     ReducerRegistry,
 -     setStateProperties,
 -     setStateProperty
 - } from '../redux';
 - 
 - import {
 -     CONFERENCE_FAILED,
 -     CONFERENCE_JOINED,
 -     CONFERENCE_LEFT,
 -     CONFERENCE_WILL_LEAVE,
 -     SET_PASSWORD,
 -     SET_ROOM
 - } from './actionTypes';
 - import { isRoomValid } from './functions';
 - 
 - /**
 -  * 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 = {}, action) => {
 -     switch (action.type) {
 -     case CONFERENCE_FAILED:
 -         return _conferenceFailed(state, action);
 - 
 -     case CONFERENCE_JOINED:
 -         return _conferenceJoined(state, action);
 - 
 -     case CONFERENCE_LEFT:
 -         return _conferenceLeft(state, action);
 - 
 -     case CONFERENCE_WILL_LEAVE:
 -         return _conferenceWillLeave(state, action);
 - 
 -     case SET_PASSWORD:
 -         return _setPassword(state, action);
 - 
 -     case SET_ROOM:
 -         return _setRoom(state, action);
 -     }
 - 
 -     return state;
 - });
 - 
 - /**
 -  * Reduces a specific Redux action CONFERENCE_FAILED of the feature
 -  * base/conference.
 -  *
 -  * @param {Object} state - The Redux state of the feature base/conference.
 -  * @param {Action} action - The Redux action CONFERENCE_FAILED to reduce.
 -  * @private
 -  * @returns {Object} The new state of the feature base/conference after the
 -  * reduction of the specified action.
 -  */
 - function _conferenceFailed(state, action) {
 -     const conference = action.conference;
 - 
 -     if (state.conference && state.conference !== conference) {
 -         return state;
 -     }
 - 
 -     const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
 -     const passwordRequired
 -         = JitsiConferenceErrors.PASSWORD_REQUIRED === action.error
 -             ? conference
 -             : undefined;
 - 
 -     return (
 -         setStateProperties(state, {
 -             conference: undefined,
 -             leaving: undefined,
 -             password: undefined,
 - 
 -             /**
 -              * The JitsiConference instance which requires a password to join.
 -              *
 -              * @type {JitsiConference}
 -              */
 -             passwordRequired
 -         }));
 - }
 - 
 - /**
 -  * Reduces a specific Redux action CONFERENCE_JOINED of the feature
 -  * base/conference.
 -  *
 -  * @param {Object} state - The Redux state of the feature base/conference.
 -  * @param {Action} action - The Redux action CONFERENCE_JOINED to reduce.
 -  * @private
 -  * @returns {Object} The new state of the feature base/conference after the
 -  * reduction of the specified action.
 -  */
 - function _conferenceJoined(state, action) {
 -     return (
 -         setStateProperties(state, {
 -             /**
 -              * The JitsiConference instance represented by the Redux state of
 -              * the feature base/conference.
 -              *
 -              * @type {JitsiConference}
 -              */
 -             conference: action.conference,
 -             leaving: undefined,
 -             passwordRequired: undefined
 -         }));
 - }
 - 
 - /**
 -  * Reduces a specific Redux action CONFERENCE_LEFT of the feature
 -  * base/conference.
 -  *
 -  * @param {Object} state - The Redux state of the feature base/conference.
 -  * @param {Action} action - The Redux action CONFERENCE_LEFT to reduce.
 -  * @private
 -  * @returns {Object} The new state of the feature base/conference after the
 -  * reduction of the specified action.
 -  */
 - function _conferenceLeft(state, action) {
 -     const conference = action.conference;
 - 
 -     if (state.conference !== conference) {
 -         return state;
 -     }
 - 
 -     return (
 -         setStateProperties(state, {
 -             conference: undefined,
 -             leaving: undefined,
 -             password: undefined,
 -             passwordRequired: undefined
 -         }));
 - }
 - 
 - /**
 -  * Reduces a specific Redux action CONFERENCE_WILL_LEAVE of the feature
 -  * base/conference.
 -  *
 -  * @param {Object} state - The Redux state of the feature base/conference.
 -  * @param {Action} action - The Redux action CONFERENCE_WILL_LEAVE to reduce.
 -  * @private
 -  * @returns {Object} The new state of the feature base/conference after the
 -  * reduction of the specified action.
 -  */
 - function _conferenceWillLeave(state, action) {
 -     const conference = action.conference;
 - 
 -     if (state.conference !== conference) {
 -         return state;
 -     }
 - 
 -     return (
 -         setStateProperties(state, {
 -             /**
 -              * The JitsiConference instance which is currently in the process of
 -              * being left.
 -              *
 -              * @type {JitsiConference}
 -              */
 -             leaving: conference,
 -             passwordRequired: undefined
 -         }));
 - }
 - 
 - /**
 -  * Reduces a specific Redux action SET_PASSWORD of the feature base/conference.
 -  *
 -  * @param {Object} state - The Redux state of the feature base/conference.
 -  * @param {Action} action - The Redux action SET_PASSWORD to reduce.
 -  * @private
 -  * @returns {Object} The new state of the feature base/conference after the
 -  * reduction of the specified action.
 -  */
 - function _setPassword(state, action) {
 -     const conference = action.conference;
 - 
 -     switch (action.method) {
 -     case conference.join:
 -         if (state.passwordRequired === conference) {
 -             return (
 -                 setStateProperties(state, {
 -                     /**
 -                      * The password with which the conference is to be joined.
 -                      *
 -                      * @type {string}
 -                      */
 -                     password: action.password,
 -                     passwordRequired: undefined
 -                 }));
 -         }
 -         break;
 -     }
 - 
 -     return state;
 - }
 - 
 - /**
 -  * Reduces a specific Redux action SET_ROOM of the feature base/conference.
 -  *
 -  * @param {Object} state - The Redux state of the feature base/conference.
 -  * @param {Action} action - The Redux action SET_ROOM to reduce.
 -  * @private
 -  * @returns {Object} The new state of the feature base/conference after the
 -  * reduction of the specified action.
 -  */
 - function _setRoom(state, action) {
 -     let room = action.room;
 - 
 -     if (isRoomValid(room)) {
 -         // XXX Lib-jitsi-meet does not accept uppercase letters.
 -         room = room.toLowerCase();
 -     } else {
 -         // Technically, there are 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.
 -         room = undefined;
 -     }
 - 
 -     /**
 -      * The name of the room of the conference (to be) joined.
 -      *
 -      * @type {string}
 -      */
 -     return setStateProperty(state, 'room', room);
 - }
 
 
  |