From 623b7a8d6f7d47218f9cd73e397b46806d1f778f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 29 Mar 2017 11:26:46 +0200 Subject: [PATCH] [RN] Show avatar if a participant is not in last N --- react/features/base/conference/actions.js | 29 +++++++++++++++++++ react/features/base/participants/actions.js | 24 +++++++++++++++ .../components/ParticipantView.native.js | 24 +++++++++++---- react/features/base/participants/reducer.js | 12 ++++++-- 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index ace53e439..b3f3c9c2a 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -1,5 +1,6 @@ import { JitsiConferenceEvents } from '../lib-jitsi-meet'; import { + changeParticipantLastNStatus, dominantSpeakerChanged, getLocalParticipant, participantJoined, @@ -52,6 +53,10 @@ function _addConferenceListeners(conference, dispatch) { JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, (...args) => dispatch(dominantSpeakerChanged(...args))); + conference.on( + JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED, + (...args) => _lastNEndpointsChanged(dispatch, ...args)); + conference.on( JitsiConferenceEvents.LOCK_STATE_CHANGED, (...args) => dispatch(_lockStateChanged(conference, ...args))); @@ -263,6 +268,30 @@ export function createConference() { }; } +/** + * Handles the lastN status changes for participants in the current conference. + * Signals that a participant's lastN status has changed, for each participant + * who entered or left the last N set. + * + * @param {Dispatch} dispatch - Redux dispatch function. + * @param {Array} leavingIds - Ids of participants who are leaving the last N + * set. + * @param {Array} enteringIds - Ids of participants who are entering the last N + * set. + * @returns {void} + * + * @private + */ +function _lastNEndpointsChanged(dispatch, leavingIds = [], enteringIds = []) { + for (const id of leavingIds) { + dispatch(changeParticipantLastNStatus(id, false)); + } + + for (const id of enteringIds) { + dispatch(changeParticipantLastNStatus(id, true)); + } +} + /** * Signals that the lock state of a specific JitsiConference changed. * diff --git a/react/features/base/participants/actions.js b/react/features/base/participants/actions.js index c84fbdc77..57bbca230 100644 --- a/react/features/base/participants/actions.js +++ b/react/features/base/participants/actions.js @@ -8,6 +8,30 @@ import { } from './actionTypes'; import { getLocalParticipant } from './functions'; +/** + * Action to update a participant's lastN status. + * + * @param {string} id - Participant's ID. + * @param {boolean} isInLastN - True if the participant is in the lastN + * endpoints set, false otherwise. + * @returns {{ + * type: PARTICIPANT_UPDATED, + * participant: { + * id: string, + * isInLastN: boolean + * } + * }} + */ +export function changeParticipantLastNStatus(id, isInLastN) { + return { + type: PARTICIPANT_UPDATED, + participant: { + id, + isInLastN + } + }; +} + /** * Create an action for when dominant speaker changes. * diff --git a/react/features/base/participants/components/ParticipantView.native.js b/react/features/base/participants/components/ParticipantView.native.js index ed64d9598..4f1c4bbb1 100644 --- a/react/features/base/participants/components/ParticipantView.native.js +++ b/react/features/base/participants/components/ParticipantView.native.js @@ -34,6 +34,13 @@ class ParticipantView extends Component { */ _avatar: React.PropTypes.string, + /** + * True if the participant is in the last N endpoints set, false if he + * isn't. If undefined, we have no indication, so the same course of + * action as true is taken. + */ + _isInLastN: React.PropTypes.bool, + /** * The video Track of the participant with {@link #participantId}. */ @@ -85,20 +92,23 @@ class ParticipantView extends Component { * @returns {ReactElement} */ render() { - // Is the video to be rendered? - const videoTrack = this.props._videoTrack; + const { + _avatar: avatar, + _isInLastN: isInLastN, + _videoTrack: videoTrack + } = this.props; + // Is the video to be rendered? // FIXME It's currently impossible to have true as the value of // waitForVideoStarted because videoTrack's state videoStarted will be // updated only after videoTrack is rendered. const waitForVideoStarted = false; const renderVideo - = shouldRenderVideoTrack(videoTrack, waitForVideoStarted); + = shouldRenderVideoTrack(videoTrack, waitForVideoStarted) + && (typeof isInLastN === 'undefined' || isInLastN); // Is the avatar to be rendered? - const avatar = this.props._avatar; - const renderAvatar - = !renderVideo && typeof avatar !== 'undefined' && avatar !== ''; + const renderAvatar = Boolean(!renderVideo && avatar); return (