Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(base/conference): clear the 'conference' field on WILL_LEAVE

paweldomas11b7144ad004
diff --git a/react/features/base/conference/reducer.js b/react/features/base/conference/reducer.js
index 91790fdde1..0266bb8dbd 100644
--- a/react/features/base/conference/reducer.js
+++ b/react/features/base/conference/reducer.js
@@ -38,14 +38,12 @@ ReducerRegistry.register('features/base/conference', (state = {}, action) => {
return _conferenceJoined(state, action);
case CONFERENCE_LEFT:
- return _conferenceLeft(state, action);
+ case CONFERENCE_WILL_LEAVE:
+ return _conferenceLeftOrWillLeave(state, action);
case CONFERENCE_WILL_JOIN:
return _conferenceWillJoin(state, action);
- case CONFERENCE_WILL_LEAVE:
- return _conferenceWillLeave(state, action);
-
case CONNECTION_WILL_CONNECT:
return set(state, 'authRequired', undefined);
@@ -197,41 +195,70 @@ function _conferenceJoined(state, { conference }) {
}
/**
- * Reduces a specific Redux action CONFERENCE_LEFT of the feature
- * base/conference.
+ * Reduces a specific redux action {@link CONFERENCE_LEFT} or
+ * {@link CONFERENCE_WILL_LEAVE} for 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.
+ * @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.
* @private
- * @returns {Object} The new state of the feature base/conference after the
+ * @returns {Object} The next/new state of the feature base/conference after the
* reduction of the specified action.
*/
-function _conferenceLeft(state, { conference }) {
+function _conferenceLeftOrWillLeave(state, { conference, type }) {
let nextState = state;
- if (state.authRequired === conference) {
- nextState = set(nextState, 'authRequired', undefined);
- }
- if (state.conference === conference) {
- nextState = assign(nextState, {
- conference: undefined,
- joining: undefined,
- leaving: undefined,
-
- // XXX Clear/unset locked & password here for a conference which has
- // been LOCKED_LOCALLY.
- locked: undefined,
- password: undefined
- });
+ // 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) {
+ if (p !== 'leaving' && state[p] === conference) {
+ nextState = set(nextState, p, undefined);
+
+ switch (p) {
+ case 'conference':
+ // XXX Clear/unset locked & password for a conference which has
+ // been LOCKED_LOCALLY.
+ delete nextState.locked;
+ delete nextState.password;
+ break;
+
+ case 'passwordRequired':
+ // XXX Clear/unset locked & password for a conference which has
+ // been LOCKED_REMOTELY.
+ delete nextState.locked;
+ delete nextState.password;
+ break;
+ }
+ }
}
- if (state.passwordRequired === conference) {
- nextState = assign(nextState, {
- // XXX Clear/unset locked & password here for a conference which has
- // been LOCKED_REMOTELY.
- locked: undefined,
- password: undefined,
- passwordRequired: undefined
- });
+
+ // leaving
+ switch (type) {
+ case CONFERENCE_LEFT:
+ if (state.leaving === conference) {
+ nextState = set(nextState, 'leaving', undefined);
+ }
+ break;
+
+ case CONFERENCE_WILL_LEAVE:
+ // 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}
+ */
+ nextState = set(nextState, 'leaving', conference);
+ }
+ break;
}
return nextState;
@@ -254,36 +281,6 @@ function _conferenceWillJoin(state, { conference }) {
});
}
-/**
- * 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, { conference }) {
- if (state.conference !== conference) {
- return state;
- }
-
- return assign(state, {
- authRequired: undefined,
- joining: undefined,
-
- /**
- * The JitsiConference instance which is currently in the process of
- * being left.
- *
- * @type {JitsiConference}
- */
- leaving: conference,
- passwordRequired: undefined
- });
-}
-
/**
* Reduces a specific Redux action LOCK_STATE_CHANGED of the feature
* base/conference.