Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[RN] Unpin participant and set last N to 1 if the filmstrip is disabled (Coding style: consistency)
Lyubo Marinov10f72f8e407a
diff --git a/react/features/base/conference/middleware.js b/react/features/base/conference/middleware.jsindex 4a3debfc2d..8f16e4d672 100644--- a/react/features/base/conference/middleware.js+++ b/react/features/base/conference/middleware.js@@ -1,7 +1,5 @@// @flow-import UIEvents from '../../../../service/UI/UIEvents';-import {ACTION_PINNED,ACTION_UNPINNED,@@ -18,6 +16,7 @@ import {PIN_PARTICIPANT} from '../participants';import { MiddlewareRegistry } from '../redux';+import UIEvents from '../../../../service/UI/UIEvents';import { TRACK_ADDED, TRACK_REMOVED } from '../tracks';import {@@ -97,16 +96,15 @@ MiddlewareRegistry.register(store => next => action => {* @param {Action} action - The redux action CONNECTION_ESTABLISHED which is* being dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/-function _connectionEstablished(store, next, action) {+function _connectionEstablished({ dispatch }, next, action) {const result = next(action);// FIXME: workaround for the web version. Currently the creation of the// conference is handled by /conference.jsif (typeof APP === 'undefined') {- store.dispatch(createConference());+ dispatch(createConference());}return result;@@ -123,8 +121,7 @@ function _connectionEstablished(store, next, action) {* @param {Action} action - The redux action {@link CONFERENCE_FAILED} or* {@link CONFERENCE_LEFT} which is being dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/function _conferenceFailedOrLeft({ dispatch, getState }, next, action) {const result = next(action);@@ -149,20 +146,17 @@ function _conferenceFailedOrLeft({ dispatch, getState }, next, action) {* @param {Action} action - The redux action CONFERENCE_JOINED which is being* dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/-function _conferenceJoined(store, next, action) {+function _conferenceJoined({ dispatch, getState }, next, action) {const result = next(action);- const { audioOnly, conference }- = store.getState()['features/base/conference'];++ const { audioOnly, conference } = getState()['features/base/conference'];// FIXME On Web the audio only mode for "start audio only" is toggled before// conference is added to the redux store ("on conference joined" action)// and the LastN value needs to be synchronized here.- if (audioOnly && conference.getLastN() !== 0) {- store.dispatch(setLastN(0));- }+ audioOnly && (conference.getLastN() !== 0) && dispatch(setLastN(0));return result;}@@ -179,11 +173,10 @@ function _conferenceJoined(store, next, action) {* @param {Action} action - The redux action PIN_PARTICIPANT which is being* dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/-function _pinParticipant(store, next, action) {- const state = store.getState();+function _pinParticipant({ getState }, next, action) {+ const state = getState();const { conference } = state['features/base/conference'];if (!conference) {@@ -248,8 +241,7 @@ function _pinParticipant(store, next, action) {* @param {Action} action - The redux action SET_AUDIO_ONLY which is being* dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/function _setAudioOnly({ dispatch, getState }, next, action) {const result = next(action);@@ -286,11 +278,10 @@ function _setAudioOnly({ dispatch, getState }, next, action) {* @param {Action} action - The redux action SET_LASTN which is being dispatched* in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/-function _setLastN(store, next, action) {- const { conference } = store.getState()['features/base/conference'];+function _setLastN({ getState }, next, action) {+ const { conference } = getState()['features/base/conference'];if (conference) {try {@@ -307,24 +298,21 @@ function _setLastN(store, next, action) {* Sets the maximum receive video quality and will turn off audio only mode if* enabled.*- * @param {Store} store - The Redux store in which the specified action is being+ * @param {Store} store - The redux store in which the specified action is being* dispatched.- * @param {Dispatch} next - The Redux dispatch function to dispatch the+ * @param {Dispatch} next - The redux dispatch function to dispatch the* specified action to the specified store.- * @param {Action} action - The Redux action SET_RECEIVE_VIDEO_QUALITY which is+ * @param {Action} action - The redux action SET_RECEIVE_VIDEO_QUALITY which is* being dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/function _setReceiveVideoQuality({ dispatch, getState }, next, action) {const { audioOnly, conference } = getState()['features/base/conference'];if (conference) {conference.setReceiverVideoConstraint(action.receiveVideoQuality);- if (audioOnly) {- dispatch(toggleAudioOnly());- }+ audioOnly && dispatch(toggleAudioOnly());}return next(action);@@ -362,15 +350,14 @@ function _syncConferenceLocalTracksWithState({ getState }, action) {/*** Sets the maximum receive video quality.*- * @param {Store} store - The Redux store in which the specified action is being+ * @param {Store} store - The redux store in which the specified action is being* dispatched.- * @param {Dispatch} next - The Redux dispatch function to dispatch the+ * @param {Dispatch} next - The redux dispatch function to dispatch the* specified action to the specified store.- * @param {Action} action - The Redux action DATA_CHANNEL_STATUS_CHANGED which+ * @param {Action} action - The redux action DATA_CHANNEL_STATUS_CHANGED which* is being dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/function _syncReceiveVideoQuality({ getState }, next, action) {const state = getState()['features/base/conference'];@@ -391,8 +378,7 @@ function _syncReceiveVideoQuality({ getState }, next, action) {* @param {Action} action - The redux action TRACK_ADDED or TRACK_REMOVED which* is being dispatched in the specified store.* @private- * @returns {Object} The new state that is the result of the reduction of the- * specified action.+ * @returns {Object} The value returned by {@code next(action)}.*/function _trackAddedOrRemoved(store, next, action) {const track = action.track;diff --git a/react/features/filmstrip/middleware.js b/react/features/filmstrip/middleware.jsindex 0c2c85cca9..c7d2f7bf16 100644--- a/react/features/filmstrip/middleware.js+++ b/react/features/filmstrip/middleware.js@@ -4,51 +4,95 @@ import { setLastN } from '../base/conference';import { SET_CALLEE_INFO_VISIBLE } from '../base/jwt';import { pinParticipant } from '../base/participants';import { MiddlewareRegistry } from '../base/redux';-import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';import { SET_FILMSTRIP_ENABLED } from './actionTypes';declare var APP: Object;-MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {+MiddlewareRegistry.register(store => next => action => {switch (action.type) {case SET_CALLEE_INFO_VISIBLE:- if (typeof APP !== 'undefined') {- const oldValue- = Boolean(getState()['features/base/jwt'].calleeInfoVisible);- const result = next(action);- const newValue- = Boolean(getState()['features/base/jwt'].calleeInfoVisible);-- oldValue === newValue-- // FIXME The following accesses the private state filmstrip of- // Filmstrip. It is written with the understanding that- // Filmstrip will be rewritten in React and, consequently, will- // not need the middleware implemented here, Filmstrip.init, and- // UI.start.- || (Filmstrip.filmstrip- && Filmstrip.toggleFilmstrip(!newValue));-- return result;- }- break;+ return _setCalleeInfoVisible(store, next, action);case SET_FILMSTRIP_ENABLED:- // FIXME: Only do this on mobile for now. The logic for participant- // pinning / unpinning is not on React yet so dispatching the action- // is not enough.- if (typeof APP === 'undefined') {- const { audioOnly } = getState()['features/base/conference'];- const { enabled } = action;-- !enabled && dispatch(pinParticipant(null));- !audioOnly && dispatch(setLastN(enabled ? undefined : 1));- }- break;-+ return _setFilmstripEnabled(store, next, action);}return next(action);});++/**+ * Notifies the feature filmstrip that the action+ * {@link SET_CALLEE_INFO_VISIBLE} is being dispatched within a specific redux+ * store.+ *+ * @param {Store} store - The redux store in which the specified action is being+ * dispatched.+ * @param {Dispatch} next - The redux dispatch function to dispatch the+ * specified action to the specified store.+ * @param {Action} action - The redux action {@code SET_CALLEE_INFO_VISIBLE}+ * which is being dispatched in the specified store.+ * @private+ * @returns {Object} The value returned by {@code next(action)}.+ */+function _setCalleeInfoVisible({ getState }, next, action) {+ if (typeof APP !== 'undefined') {+ const oldValue+ = Boolean(getState()['features/base/jwt'].calleeInfoVisible);+ const result = next(action);+ const newValue+ = Boolean(getState()['features/base/jwt'].calleeInfoVisible);++ oldValue === newValue++ // FIXME The following accesses the private state filmstrip of+ // Filmstrip. It is written with the understanding that Filmstrip+ // will be rewritten in React and, consequently, will not need the+ // middleware implemented here, Filmstrip.init, and UI.start.+ || (Filmstrip.filmstrip && Filmstrip.toggleFilmstrip(!newValue));++ return result;+ }++ return next(action);+}++/**+ * Notifies the feature filmstrip that the action {@link SET_FILMSTRIP_ENABLED}+ * is being dispatched within a specific redux store.+ *+ * @param {Store} store - The redux store in which the specified action is being+ * dispatched.+ * @param {Dispatch} next - The redux dispatch function to dispatch the+ * specified action to the specified store.+ * @param {Action} action - The redux action {@code SET_FILMSTRIP_ENABLED} which+ * is being dispatched in the specified store.+ * @private+ * @returns {Object} The value returned by {@code next(action)}.+ */+function _setFilmstripEnabled({ dispatch, getState }, next, action) {+ const result = next(action);++ // FIXME The logic for participant pinning / unpinning is not on React yet+ // so dispatching the action is not enough. Hence, perform the following+ // only where it will be sufficient i.e. mobile.+ if (typeof APP === 'undefined') {+ const state = getState();+ const { enabled } = state['features/filmstrip'];+ const { audioOnly } = state['features/base/conference'];++ enabled || dispatch(pinParticipant(null));++ // FIXME Audio-only mode fiddles with lastN as well. That's why we don't+ // touch lastN in audio-only mode. But it's not clear what the value of+ // lastN should be upon exit from audio-only mode if the filmstrip is+ // disabled already. Currently, audio-only mode will set undefined+ // regardless of whether the filmstrip is disabled. But we don't have a+ // practical use case in which audio-only mode is exited while the+ // filmstrip is disabled.+ audioOnly || dispatch(setLastN(enabled ? undefined : 1));+ }++ return result;+}