[RN] Fix pinParticipant if we are not yet in a conference

It may happen that such action is fired while joining.
This commit is contained in:
Saúl Ibarra Corretgé 2018-01-31 17:37:41 +01:00 committed by Lyubo Marinov
parent b4d44f367d
commit da0ae73d10
1 changed files with 12 additions and 8 deletions

View File

@ -185,26 +185,29 @@ function _conferenceJoined(store, next, action) {
function _pinParticipant(store, next, action) { function _pinParticipant(store, next, action) {
const state = store.getState(); const state = store.getState();
const { conference } = state['features/base/conference']; const { conference } = state['features/base/conference'];
if (!conference) {
return next(action);
}
const participants = state['features/base/participants']; const participants = state['features/base/participants'];
const id = action.participant.id; const id = action.participant.id;
const participantById = getParticipantById(participants, id); const participantById = getParticipantById(participants, id);
let pin;
if (typeof APP !== 'undefined') { if (typeof APP !== 'undefined') {
const pinnedParticipant = getPinnedParticipant(participants); const pinnedParticipant = getPinnedParticipant(participants);
const actionName const actionName = id ? ACTION_PINNED : ACTION_UNPINNED;
= action.participant.id ? ACTION_PINNED : ACTION_UNPINNED; const local
const local = (participantById && participantById.local) = (participantById && participantById.local)
|| (!id && pinnedParticipant && pinnedParticipant.local); || (!id && pinnedParticipant && pinnedParticipant.local);
sendAnalytics(createPinnedEvent( sendAnalytics(createPinnedEvent(
actionName, actionName,
local ? 'local' : id, local ? 'local' : id,
{ {
'participant_count': conference.getParticipantCount(), local,
local 'participant_count': conference.getParticipantCount()
})); }));
} }
// The following condition prevents signaling to pin local participant and // 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 // - 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 // 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. // action will unpin her and that's why we won't signal here too.
let pin;
if (participantById) { if (participantById) {
pin = !participantById.local && !participantById.isBot; pin = !participantById.local && !participantById.isBot;
} else { } else {
@ -222,7 +227,6 @@ function _pinParticipant(store, next, action) {
pin = !localParticipant || !localParticipant.pinned; pin = !localParticipant || !localParticipant.pinned;
} }
if (pin) { if (pin) {
try { try {
conference.pinParticipant(id); conference.pinParticipant(id);
} catch (err) { } catch (err) {