2017-10-04 22:36:09 +00:00
|
|
|
// @flow
|
|
|
|
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
import { CONNECTION_WILL_CONNECT, SET_LOCATION_URL } from '../connection';
|
2017-02-28 03:21:50 +00:00
|
|
|
import { JitsiConferenceErrors } from '../lib-jitsi-meet';
|
2017-04-22 22:57:08 +00:00
|
|
|
import { assign, ReducerRegistry, set } from '../redux';
|
2017-09-22 20:09:04 +00:00
|
|
|
import { LOCKED_LOCALLY, LOCKED_REMOTELY } from '../../room-lock';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
import {
|
2018-06-20 20:19:53 +00:00
|
|
|
AUTH_STATUS_CHANGED,
|
2016-12-12 01:02:50 +00:00
|
|
|
CONFERENCE_FAILED,
|
2016-10-05 14:36:59 +00:00
|
|
|
CONFERENCE_JOINED,
|
|
|
|
CONFERENCE_LEFT,
|
2019-03-12 17:45:53 +00:00
|
|
|
CONFERENCE_SUBJECT_CHANGED,
|
2017-07-06 11:51:35 +00:00
|
|
|
CONFERENCE_WILL_JOIN,
|
2016-10-05 14:36:59 +00:00
|
|
|
CONFERENCE_WILL_LEAVE,
|
2016-12-12 19:49:23 +00:00
|
|
|
LOCK_STATE_CHANGED,
|
2017-08-09 19:40:03 +00:00
|
|
|
P2P_STATUS_CHANGED,
|
2017-03-29 12:07:05 +00:00
|
|
|
SET_AUDIO_ONLY,
|
2018-03-07 00:28:19 +00:00
|
|
|
SET_DESKTOP_SHARING_ENABLED,
|
2017-11-21 02:21:35 +00:00
|
|
|
SET_FOLLOW_ME,
|
2018-07-24 16:23:38 +00:00
|
|
|
SET_MAX_RECEIVER_VIDEO_QUALITY,
|
2016-12-12 01:02:50 +00:00
|
|
|
SET_PASSWORD,
|
2019-03-12 17:45:53 +00:00
|
|
|
SET_PENDING_SUBJECT_CHANGE,
|
2018-07-23 22:42:57 +00:00
|
|
|
SET_PREFERRED_RECEIVER_VIDEO_QUALITY,
|
2017-10-03 16:30:42 +00:00
|
|
|
SET_ROOM,
|
2017-11-21 02:21:35 +00:00
|
|
|
SET_SIP_GATEWAY_ENABLED,
|
|
|
|
SET_START_MUTED_POLICY
|
2016-10-05 14:36:59 +00:00
|
|
|
} from './actionTypes';
|
2017-09-28 21:25:04 +00:00
|
|
|
import { VIDEO_QUALITY_LEVELS } from './constants';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { isRoomValid } from './functions';
|
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
const DEFAULT_STATE = {
|
2018-10-03 09:29:19 +00:00
|
|
|
conference: undefined,
|
2018-07-24 20:43:09 +00:00
|
|
|
joining: undefined,
|
2018-10-03 09:29:19 +00:00
|
|
|
leaving: undefined,
|
|
|
|
locked: undefined,
|
2018-07-24 20:43:09 +00:00
|
|
|
maxReceiverVideoQuality: VIDEO_QUALITY_LEVELS.HIGH,
|
2018-10-03 09:29:19 +00:00
|
|
|
password: undefined,
|
|
|
|
passwordRequired: undefined,
|
2018-07-24 20:43:09 +00:00
|
|
|
preferredReceiverVideoQuality: VIDEO_QUALITY_LEVELS.HIGH
|
|
|
|
};
|
|
|
|
|
2016-12-12 00:29:13 +00:00
|
|
|
/**
|
|
|
|
* Listen for actions that contain the conference object, so that it can be
|
|
|
|
* stored for use by other action creators.
|
|
|
|
*/
|
2018-07-24 20:43:09 +00:00
|
|
|
ReducerRegistry.register(
|
|
|
|
'features/base/conference',
|
|
|
|
(state = DEFAULT_STATE, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case AUTH_STATUS_CHANGED:
|
|
|
|
return _authStatusChanged(state, action);
|
2018-06-20 20:19:53 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case CONFERENCE_FAILED:
|
|
|
|
return _conferenceFailed(state, action);
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case CONFERENCE_JOINED:
|
|
|
|
return _conferenceJoined(state, action);
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-03-12 17:45:53 +00:00
|
|
|
case CONFERENCE_SUBJECT_CHANGED:
|
|
|
|
return set(state, 'subject', action.subject);
|
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case CONFERENCE_LEFT:
|
|
|
|
case CONFERENCE_WILL_LEAVE:
|
|
|
|
return _conferenceLeftOrWillLeave(state, action);
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case CONFERENCE_WILL_JOIN:
|
|
|
|
return _conferenceWillJoin(state, action);
|
2017-07-06 11:51:35 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case CONNECTION_WILL_CONNECT:
|
|
|
|
return set(state, 'authRequired', undefined);
|
2017-09-22 20:09:04 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case LOCK_STATE_CHANGED:
|
|
|
|
return _lockStateChanged(state, action);
|
2016-12-12 19:49:23 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case P2P_STATUS_CHANGED:
|
|
|
|
return _p2pStatusChanged(state, action);
|
2017-08-09 19:40:03 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_AUDIO_ONLY:
|
|
|
|
return _setAudioOnly(state, action);
|
2017-03-29 12:07:05 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_DESKTOP_SHARING_ENABLED:
|
|
|
|
return _setDesktopSharingEnabled(state, action);
|
2018-03-07 00:28:19 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_FOLLOW_ME:
|
|
|
|
return set(state, 'followMeEnabled', action.enabled);
|
2017-11-21 02:21:35 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_LOCATION_URL:
|
|
|
|
return set(state, 'room', undefined);
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_MAX_RECEIVER_VIDEO_QUALITY:
|
|
|
|
return set(
|
|
|
|
state,
|
|
|
|
'maxReceiverVideoQuality',
|
|
|
|
action.maxReceiverVideoQuality);
|
2018-07-24 16:23:38 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_PASSWORD:
|
|
|
|
return _setPassword(state, action);
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2019-03-12 17:45:53 +00:00
|
|
|
case SET_PENDING_SUBJECT_CHANGE:
|
|
|
|
return set(state, 'pendingSubjectChange', action.subject);
|
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_PREFERRED_RECEIVER_VIDEO_QUALITY:
|
|
|
|
return set(
|
|
|
|
state,
|
|
|
|
'preferredReceiverVideoQuality',
|
|
|
|
action.preferredReceiverVideoQuality);
|
2017-08-09 19:40:03 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_ROOM:
|
|
|
|
return _setRoom(state, action);
|
2017-10-03 16:30:42 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_SIP_GATEWAY_ENABLED:
|
|
|
|
return _setSIPGatewayEnabled(state, action);
|
2017-11-21 02:21:35 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
case SET_START_MUTED_POLICY:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
startAudioMutedPolicy: action.startAudioMutedPolicy,
|
|
|
|
startVideoMutedPolicy: action.startVideoMutedPolicy
|
|
|
|
};
|
|
|
|
}
|
2016-12-12 00:29:13 +00:00
|
|
|
|
2018-07-24 20:43:09 +00:00
|
|
|
return state;
|
|
|
|
});
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-06-20 20:19:53 +00:00
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action AUTH_STATUS_CHANGED of the feature
|
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
|
|
|
* @param {Action} action - The Redux action AUTH_STATUS_CHANGED to reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
|
|
|
function _authStatusChanged(state, { authEnabled, authLogin }) {
|
|
|
|
return assign(state, {
|
|
|
|
authEnabled,
|
|
|
|
authLogin
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-07-07 17:21:08 +00:00
|
|
|
function _conferenceFailed(state, { conference, error }) {
|
2017-12-04 22:01:28 +00:00
|
|
|
// The current (similar to getCurrentConference in
|
|
|
|
// base/conference/functions.js) conference which is joining or joined:
|
2017-11-28 14:03:38 +00:00
|
|
|
const conference_ = state.conference || state.joining;
|
|
|
|
|
|
|
|
if (conference_ && conference_ !== conference) {
|
2016-12-12 01:02:50 +00:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2017-09-22 20:09:04 +00:00
|
|
|
let authRequired;
|
|
|
|
let passwordRequired;
|
|
|
|
|
2017-10-05 12:41:35 +00:00
|
|
|
switch (error.name) {
|
2017-09-22 20:09:04 +00:00
|
|
|
case JitsiConferenceErrors.AUTHENTICATION_REQUIRED:
|
|
|
|
authRequired = conference;
|
|
|
|
break;
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2017-09-22 20:09:04 +00:00
|
|
|
case JitsiConferenceErrors.PASSWORD_REQUIRED:
|
|
|
|
passwordRequired = conference;
|
|
|
|
break;
|
|
|
|
}
|
2017-09-08 13:36:42 +00:00
|
|
|
|
2017-07-07 17:21:08 +00:00
|
|
|
return assign(state, {
|
2017-09-08 13:36:42 +00:00
|
|
|
authRequired,
|
2017-07-07 17:21:08 +00:00
|
|
|
conference: undefined,
|
2017-11-09 12:48:33 +00:00
|
|
|
error,
|
2017-07-07 17:21:08 +00:00
|
|
|
joining: undefined,
|
|
|
|
leaving: undefined,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator of how the conference/room is locked. If falsy, the
|
|
|
|
* conference/room is unlocked; otherwise, it's either
|
|
|
|
* {@code LOCKED_LOCALLY} or {@code LOCKED_REMOTELY}.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
locked: passwordRequired ? LOCKED_REMOTELY : undefined,
|
|
|
|
password: undefined,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The JitsiConference instance which requires a password to join.
|
|
|
|
*
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
passwordRequired
|
|
|
|
});
|
2016-12-12 01:02:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2016-12-12 00:29:13 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2017-07-07 17:21:08 +00:00
|
|
|
function _conferenceJoined(state, { conference }) {
|
2016-12-12 19:49:23 +00:00
|
|
|
// FIXME The indicator which determines whether a JitsiConference is locked
|
|
|
|
// i.e. password-protected is private to lib-jitsi-meet. However, the
|
|
|
|
// library does not fire LOCK_STATE_CHANGED upon joining a JitsiConference
|
|
|
|
// with a password.
|
2019-06-20 17:00:13 +00:00
|
|
|
// FIXME Technically JitsiConference.room is a private field.
|
|
|
|
const locked = conference.room && conference.room.locked ? LOCKED_REMOTELY : undefined;
|
2016-12-12 19:49:23 +00:00
|
|
|
|
2017-07-07 17:21:08 +00:00
|
|
|
return assign(state, {
|
2017-09-08 13:36:42 +00:00
|
|
|
authRequired: undefined,
|
|
|
|
|
2017-07-07 17:21:08 +00:00
|
|
|
/**
|
|
|
|
* The JitsiConference instance represented by the Redux state of the
|
|
|
|
* feature base/conference.
|
|
|
|
*
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
conference,
|
|
|
|
joining: undefined,
|
|
|
|
leaving: undefined,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the conference is locked.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
locked,
|
2018-07-24 20:43:09 +00:00
|
|
|
passwordRequired: undefined
|
2017-07-07 17:21:08 +00:00
|
|
|
});
|
2016-12-12 00:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-25 18:24:36 +00:00
|
|
|
* Reduces a specific redux action {@link CONFERENCE_LEFT} or
|
|
|
|
* {@link CONFERENCE_WILL_LEAVE} for the feature base/conference.
|
2016-12-12 00:29:13 +00:00
|
|
|
*
|
2018-05-25 18:24:36 +00:00
|
|
|
* @param {Object} state - The redux state of the feature base/conference.
|
|
|
|
* @param {Action} action - The redux action {@code CONFERENCE_LEFT} or
|
|
|
|
* {@code CONFERENCE_WILL_LEAVE} to reduce.
|
2016-12-12 00:29:13 +00:00
|
|
|
* @private
|
2018-05-25 18:24:36 +00:00
|
|
|
* @returns {Object} The next/new state of the feature base/conference after the
|
2016-12-12 00:29:13 +00:00
|
|
|
* reduction of the specified action.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2018-05-25 18:24:36 +00:00
|
|
|
function _conferenceLeftOrWillLeave(state, { conference, type }) {
|
2018-05-29 10:31:27 +00:00
|
|
|
const nextState = { ...state };
|
2017-10-20 17:53:10 +00:00
|
|
|
|
2018-05-25 18:24:36 +00:00
|
|
|
// The redux action CONFERENCE_LEFT is the last time that we should be
|
|
|
|
// hearing from a JitsiConference instance.
|
|
|
|
//
|
|
|
|
// The redux action CONFERENCE_WILL_LEAVE represents the order of the user
|
|
|
|
// to leave a JitsiConference instance. From the user's perspective, there's
|
|
|
|
// no going back (with respect to the instance itself). The app will perform
|
|
|
|
// due clean-up like leaving the associated room, but the instance is no
|
|
|
|
// longer the focus of the attention of the user and, consequently, the app.
|
|
|
|
for (const p in state) {
|
2018-05-29 10:31:27 +00:00
|
|
|
if (state[p] === conference) {
|
|
|
|
nextState[p] = undefined;
|
2018-05-25 18:24:36 +00:00
|
|
|
|
|
|
|
switch (p) {
|
|
|
|
case 'conference':
|
|
|
|
case 'passwordRequired':
|
|
|
|
// XXX Clear/unset locked & password for a conference which has
|
2018-05-29 10:31:27 +00:00
|
|
|
// been LOCKED_LOCALLY or LOCKED_REMOTELY.
|
2018-05-25 18:24:36 +00:00
|
|
|
delete nextState.locked;
|
|
|
|
delete nextState.password;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-10-20 17:53:10 +00:00
|
|
|
}
|
2018-05-25 18:24:36 +00:00
|
|
|
|
2018-05-29 10:31:27 +00:00
|
|
|
if (type === CONFERENCE_WILL_LEAVE) {
|
2018-05-25 18:24:36 +00:00
|
|
|
// A CONFERENCE_WILL_LEAVE is of further consequence only if it is
|
|
|
|
// expected i.e. if the specified conference is joining or joined.
|
|
|
|
if (conference === state.joining || conference === state.conference) {
|
|
|
|
/**
|
|
|
|
* The JitsiConference instance which is currently in the process of
|
|
|
|
* being left.
|
|
|
|
*
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
2018-05-29 10:31:27 +00:00
|
|
|
nextState.leaving = conference;
|
2018-05-25 18:24:36 +00:00
|
|
|
}
|
2016-12-12 00:29:13 +00:00
|
|
|
}
|
|
|
|
|
2017-10-24 18:58:08 +00:00
|
|
|
return nextState;
|
2016-12-12 00:29:13 +00:00
|
|
|
}
|
|
|
|
|
2017-07-06 11:51:35 +00:00
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action CONFERENCE_WILL_JOIN of the feature
|
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
|
|
|
* @param {Action} action - The Redux action CONFERENCE_WILL_JOIN to reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
2017-07-07 17:21:08 +00:00
|
|
|
function _conferenceWillJoin(state, { conference }) {
|
2017-11-09 12:48:33 +00:00
|
|
|
return assign(state, {
|
|
|
|
error: undefined,
|
|
|
|
joining: conference
|
|
|
|
});
|
2017-07-06 11:51:35 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action LOCK_STATE_CHANGED of the feature
|
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
|
|
|
* @param {Action} action - The Redux action LOCK_STATE_CHANGED to reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
2017-07-07 17:21:08 +00:00
|
|
|
function _lockStateChanged(state, { conference, locked }) {
|
|
|
|
if (state.conference !== conference) {
|
2016-12-12 19:49:23 +00:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2017-04-22 22:57:08 +00:00
|
|
|
return assign(state, {
|
2017-07-07 17:21:08 +00:00
|
|
|
locked: locked ? state.locked || LOCKED_REMOTELY : undefined,
|
|
|
|
password: locked ? state.password : undefined
|
2017-04-13 00:23:43 +00:00
|
|
|
});
|
2016-12-12 19:49:23 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 12:07:05 +00:00
|
|
|
/**
|
2017-08-09 19:40:03 +00:00
|
|
|
* Reduces a specific Redux action P2P_STATUS_CHANGED of the feature
|
2017-03-29 12:07:05 +00:00
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
2017-08-09 19:40:03 +00:00
|
|
|
* @param {Action} action - The Redux action P2P_STATUS_CHANGED to reduce.
|
2017-03-29 12:07:05 +00:00
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
2017-08-09 19:40:03 +00:00
|
|
|
function _p2pStatusChanged(state, action) {
|
|
|
|
return set(state, 'p2p', action.p2p);
|
2017-03-29 12:07:05 +00:00
|
|
|
}
|
|
|
|
|
2017-04-21 21:14:14 +00:00
|
|
|
/**
|
2017-08-09 19:40:03 +00:00
|
|
|
* Reduces a specific Redux action SET_AUDIO_ONLY of the feature
|
2017-04-21 21:14:14 +00:00
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
2017-08-09 19:40:03 +00:00
|
|
|
* @param {Action} action - The Redux action SET_AUDIO_ONLY to reduce.
|
2017-04-21 21:14:14 +00:00
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
2017-08-09 19:40:03 +00:00
|
|
|
function _setAudioOnly(state, action) {
|
|
|
|
return set(state, 'audioOnly', action.audioOnly);
|
2017-04-21 21:14:14 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action SET_DESKTOP_SHARING_ENABLED of the feature
|
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
|
|
|
* @param {Action} action - The Redux action SET_DESKTOP_SHARING_ENABLED to
|
|
|
|
* reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
|
|
|
function _setDesktopSharingEnabled(state, action) {
|
|
|
|
return set(state, 'desktopSharingEnabled', action.desktopSharingEnabled);
|
|
|
|
}
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-07-07 17:21:08 +00:00
|
|
|
function _setPassword(state, { conference, method, password }) {
|
|
|
|
switch (method) {
|
2017-04-18 21:49:52 +00:00
|
|
|
case conference.join:
|
2016-12-12 01:02:50 +00:00
|
|
|
if (state.passwordRequired === conference) {
|
2017-07-07 17:21:08 +00:00
|
|
|
return assign(state, {
|
2018-05-30 04:12:09 +00:00
|
|
|
// XXX 1. The JitsiConference which transitions away from
|
|
|
|
// passwordRequired MUST remain in the redux state
|
|
|
|
// features/base/conference until it transitions into
|
|
|
|
// conference; otherwise, there is a span of time during which
|
|
|
|
// the redux state does not even know that there is a
|
|
|
|
// JitsiConference whatsoever.
|
|
|
|
//
|
|
|
|
// 2. The redux action setPassword will attempt to join the
|
|
|
|
// JitsiConference so joining is an appropriate transitional
|
|
|
|
// redux state.
|
|
|
|
//
|
|
|
|
// 3. The redux action setPassword will perform the same check
|
|
|
|
// before it proceeds with the re-join.
|
|
|
|
joining: state.conference ? state.joining : conference,
|
2017-07-07 17:21:08 +00:00
|
|
|
locked: LOCKED_REMOTELY,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The password with which the conference is to be joined.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
password,
|
|
|
|
passwordRequired: undefined
|
|
|
|
});
|
2016-12-12 01:02:50 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-04-18 21:49:52 +00:00
|
|
|
|
|
|
|
case conference.lock:
|
2017-04-22 22:57:08 +00:00
|
|
|
return assign(state, {
|
2017-07-07 17:21:08 +00:00
|
|
|
locked: password ? LOCKED_LOCALLY : undefined,
|
|
|
|
password
|
2017-04-13 00:23:43 +00:00
|
|
|
});
|
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2016-12-07 22:04:52 +00:00
|
|
|
/**
|
|
|
|
* 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) {
|
2017-10-04 22:36:09 +00:00
|
|
|
let { room } = action;
|
2016-12-07 22:04:52 +00:00
|
|
|
|
2017-01-15 19:05:17 +00:00
|
|
|
if (!isRoomValid(room)) {
|
2016-12-07 22:04:52 +00:00
|
|
|
// 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.
|
2016-12-12 00:29:13 +00:00
|
|
|
room = undefined;
|
2016-12-07 22:04:52 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 00:29:13 +00:00
|
|
|
/**
|
|
|
|
* The name of the room of the conference (to be) joined.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2017-11-24 15:23:40 +00:00
|
|
|
return assign(state, {
|
|
|
|
error: undefined,
|
|
|
|
room
|
|
|
|
});
|
2016-12-07 22:04:52 +00:00
|
|
|
}
|
2017-10-03 16:30:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action SET_SIP_GATEWAY_ENABLED of the feature
|
|
|
|
* base/conference.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/conference.
|
|
|
|
* @param {Action} action - The Redux action SET_SIP_GATEWAY_ENABLED to reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature base/conference after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
|
|
|
function _setSIPGatewayEnabled(state, action) {
|
|
|
|
return set(state, 'isSIPGatewayEnabled', action.isSIPGatewayEnabled);
|
|
|
|
}
|