From da0ae73d1065bf202146fd050aa7b7dfe97255f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 31 Jan 2018 17:37:41 +0100 Subject: [PATCH] [RN] Fix pinParticipant if we are not yet in a conference It may happen that such action is fired while joining. --- react/features/base/conference/middleware.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/react/features/base/conference/middleware.js b/react/features/base/conference/middleware.js index 5c8cba052..934b15b58 100644 --- a/react/features/base/conference/middleware.js +++ b/react/features/base/conference/middleware.js @@ -185,26 +185,29 @@ function _conferenceJoined(store, next, action) { function _pinParticipant(store, next, action) { const state = store.getState(); const { conference } = state['features/base/conference']; + + if (!conference) { + return next(action); + } + const participants = state['features/base/participants']; const id = action.participant.id; const participantById = getParticipantById(participants, id); - let pin; if (typeof APP !== 'undefined') { const pinnedParticipant = getPinnedParticipant(participants); - const actionName - = action.participant.id ? ACTION_PINNED : ACTION_UNPINNED; - const local = (participantById && participantById.local) + const actionName = id ? ACTION_PINNED : ACTION_UNPINNED; + const local + = (participantById && participantById.local) || (!id && pinnedParticipant && pinnedParticipant.local); sendAnalytics(createPinnedEvent( actionName, local ? 'local' : id, { - 'participant_count': conference.getParticipantCount(), - local + local, + 'participant_count': conference.getParticipantCount() })); - } // The following condition prevents signaling to pin local participant and @@ -214,6 +217,8 @@ function _pinParticipant(store, next, action) { // - If we don't have an ID (i.e. no participant identified by an ID), we // check for local participant. If she's currently pinned, then this // action will unpin her and that's why we won't signal here too. + let pin; + if (participantById) { pin = !participantById.local && !participantById.isBot; } else { @@ -222,7 +227,6 @@ function _pinParticipant(store, next, action) { pin = !localParticipant || !localParticipant.pinned; } if (pin) { - try { conference.pinParticipant(id); } catch (err) {