Browse Source

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

It may happen that such action is fired while joining.
master
Saúl Ibarra Corretgé 7 years ago
parent
commit
da0ae73d10
1 changed files with 12 additions and 8 deletions
  1. 12
    8
      react/features/base/conference/middleware.js

+ 12
- 8
react/features/base/conference/middleware.js View File

@@ -185,26 +185,29 @@ function _conferenceJoined(store, next, action) {
185 185
 function _pinParticipant(store, next, action) {
186 186
     const state = store.getState();
187 187
     const { conference } = state['features/base/conference'];
188
+
189
+    if (!conference) {
190
+        return next(action);
191
+    }
192
+
188 193
     const participants = state['features/base/participants'];
189 194
     const id = action.participant.id;
190 195
     const participantById = getParticipantById(participants, id);
191
-    let pin;
192 196
 
193 197
     if (typeof APP !== 'undefined') {
194 198
         const pinnedParticipant = getPinnedParticipant(participants);
195
-        const actionName
196
-            = action.participant.id ? ACTION_PINNED : ACTION_UNPINNED;
197
-        const local = (participantById && participantById.local)
199
+        const actionName = id ? ACTION_PINNED : ACTION_UNPINNED;
200
+        const local
201
+            = (participantById && participantById.local)
198 202
                 || (!id && pinnedParticipant && pinnedParticipant.local);
199 203
 
200 204
         sendAnalytics(createPinnedEvent(
201 205
             actionName,
202 206
             local ? 'local' : id,
203 207
             {
204
-                'participant_count': conference.getParticipantCount(),
205
-                local
208
+                local,
209
+                'participant_count': conference.getParticipantCount()
206 210
             }));
207
-
208 211
     }
209 212
 
210 213
     // The following condition prevents signaling to pin local participant and
@@ -214,6 +217,8 @@ function _pinParticipant(store, next, action) {
214 217
     // - If we don't have an ID (i.e. no participant identified by an ID), we
215 218
     //   check for local participant. If she's currently pinned, then this
216 219
     //   action will unpin her and that's why we won't signal here too.
220
+    let pin;
221
+
217 222
     if (participantById) {
218 223
         pin = !participantById.local && !participantById.isBot;
219 224
     } else {
@@ -222,7 +227,6 @@ function _pinParticipant(store, next, action) {
222 227
         pin = !localParticipant || !localParticipant.pinned;
223 228
     }
224 229
     if (pin) {
225
-
226 230
         try {
227 231
             conference.pinParticipant(id);
228 232
         } catch (err) {

Loading…
Cancel
Save