From 0e9509ae9b3e46c53be31bbf429a481979398a73 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Wed, 5 Apr 2017 04:01:57 -0500 Subject: [PATCH] Comply w/ coding style --- react/features/base/conference/actions.js | 24 ++++++---- react/features/base/participants/actions.js | 48 +++++++++---------- .../components/ParticipantView.native.js | 28 +++++++---- react/features/base/participants/reducer.js | 4 +- 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index dfa30ce3a..c3e1bbba8 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -1,8 +1,8 @@ import { JitsiConferenceEvents } from '../lib-jitsi-meet'; import { - changeParticipantConnectionStatus, dominantSpeakerChanged, getLocalParticipant, + participantConnectionStatusChanged, participantJoined, participantLeft, participantRoleChanged, @@ -39,6 +39,8 @@ import type { Dispatch } from 'redux'; * @returns {void} */ function _addConferenceListeners(conference, dispatch) { + // Dispatches into features/base/conference follow: + conference.on( JitsiConferenceEvents.CONFERENCE_FAILED, (...args) => dispatch(conferenceFailed(conference, ...args))); @@ -49,18 +51,12 @@ function _addConferenceListeners(conference, dispatch) { JitsiConferenceEvents.CONFERENCE_LEFT, (...args) => dispatch(conferenceLeft(conference, ...args))); - conference.on( - JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, - (...args) => dispatch(dominantSpeakerChanged(...args))); - - conference.on( - JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED, - (...args) => dispatch(changeParticipantConnectionStatus(...args))); - conference.on( JitsiConferenceEvents.LOCK_STATE_CHANGED, (...args) => dispatch(_lockStateChanged(conference, ...args))); + // Dispatches into features/base/tracks follow: + conference.on( JitsiConferenceEvents.TRACK_ADDED, t => t && !t.isLocal() && dispatch(trackAdded(t))); @@ -68,6 +64,16 @@ function _addConferenceListeners(conference, dispatch) { JitsiConferenceEvents.TRACK_REMOVED, t => t && !t.isLocal() && dispatch(trackRemoved(t))); + // Dispatches into features/base/participants follow: + + conference.on( + JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, + (...args) => dispatch(dominantSpeakerChanged(...args))); + + conference.on( + JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED, + (...args) => dispatch(participantConnectionStatusChanged(...args))); + conference.on( JitsiConferenceEvents.USER_JOINED, (id, user) => dispatch(participantJoined({ diff --git a/react/features/base/participants/actions.js b/react/features/base/participants/actions.js index 4607816cd..d1ffab636 100644 --- a/react/features/base/participants/actions.js +++ b/react/features/base/participants/actions.js @@ -8,30 +8,6 @@ import { } from './actionTypes'; import { getLocalParticipant } from './functions'; -/** - * Action to update a participant's connection status. - * - * @param {string} id - Participant's ID. - * @param {string} connectionStatus - The new connection status for the - * participant. - * @returns {{ - * type: PARTICIPANT_UPDATED, - * participant: { - * id: string, - * connectionStatus: string - * } - * }} - */ -export function changeParticipantConnectionStatus(id, connectionStatus) { - return { - type: PARTICIPANT_UPDATED, - participant: { - id, - connectionStatus - } - }; -} - /** * Create an action for when dominant speaker changes. * @@ -93,6 +69,30 @@ export function localParticipantJoined(participant = {}) { }); } +/** + * Action to update a participant's connection status. + * + * @param {string} id - Participant's ID. + * @param {string} connectionStatus - The new connection status of the + * participant. + * @returns {{ + * type: PARTICIPANT_UPDATED, + * participant: { + * connectionStatus: string, + * id: string + * } + * }} + */ +export function participantConnectionStatusChanged(id, connectionStatus) { + return { + type: PARTICIPANT_UPDATED, + participant: { + connectionStatus, + id + } + }; +} + /** * Action to remove a local participant. * diff --git a/react/features/base/participants/components/ParticipantView.native.js b/react/features/base/participants/components/ParticipantView.native.js index 646d328f4..2b1f30467 100644 --- a/react/features/base/participants/components/ParticipantView.native.js +++ b/react/features/base/participants/components/ParticipantView.native.js @@ -36,10 +36,11 @@ class ParticipantView extends Component { _avatar: React.PropTypes.string, /** - * The connection status for the participant. Its video will only be - * rendered if the connection status is 'active', otherwise the avatar - * will be rendered. If undefined, we have no indication, so the same - * course of action as 'active' is taken. + * The connection status of the participant. Her video will only be + * rendered if the connection status is 'active'; otherwise, the avatar + * will be rendered. If undefined, 'active' is presumed. + * + * @private */ _connectionStatus: React.PropTypes.string, @@ -106,10 +107,8 @@ class ParticipantView extends Component { // updated only after videoTrack is rendered. const waitForVideoStarted = false; const renderVideo - = shouldRenderVideoTrack(videoTrack, waitForVideoStarted) - && (typeof connectionStatus === 'undefined' - || connectionStatus - === JitsiParticipantConnectionStatus.ACTIVE); + = (connectionStatus === JitsiParticipantConnectionStatus.ACTIVE) + && shouldRenderVideoTrack(videoTrack, waitForVideoStarted); // Is the avatar to be rendered? const renderAvatar = Boolean(!renderVideo && avatar); @@ -182,10 +181,19 @@ function _mapStateToProps(state, ownProps) { = getParticipantById( state['features/base/participants'], participantId); + let avatar; + let connectionStatus; + + if (participant) { + avatar = getAvatarURL(participant); + connectionStatus = participant.connectionStatus; + } return { - _avatar: participant && getAvatarURL(participant), - _connectionStatus: participant && participant.connectionStatus, + _avatar: avatar, + _connectionStatus: + connectionStatus + || JitsiParticipantConnectionStatus.ACTIVE, _videoTrack: getTrackByMediaTypeAndParticipant( state['features/base/tracks'], diff --git a/react/features/base/participants/reducer.js b/react/features/base/participants/reducer.js index cba18f861..0e3526ca8 100644 --- a/react/features/base/participants/reducer.js +++ b/react/features/base/participants/reducer.js @@ -73,9 +73,9 @@ function _participant(state, action) { const participant = action.participant; // eslint-disable-line no-shadow const { avatarURL, + connectionStatus, dominantSpeaker, email, - connectionStatus, local, pinned, role @@ -107,10 +107,10 @@ function _participant(state, action) { return { avatarID, avatarURL, + connectionStatus, dominantSpeaker: dominantSpeaker || false, email, id, - connectionStatus, local: local || false, name, pinned: pinned || false,