Browse Source

Refine PARTICIPANT_LEFT for ID collisions

If the ID of a remote participant was the same as the ID of the local
participant (across multiple conferences), removing the remote
participant on PARTICIPANT_LEFT would remove the local participant.

Like the preceding commit "ref(base/conference): clear the 'conference'
field on WILL_LEAVE", this commit is part of the story how we are to
deal with conferences which take noticeable time to leave.
master
Lyubo Marinov 7 years ago
parent
commit
c672ffd435

+ 1
- 0
react/features/base/participants/actionTypes.js View File

48
  *
48
  *
49
  * {
49
  * {
50
  *     type: PARTICIPANT_ID_CHANGED,
50
  *     type: PARTICIPANT_ID_CHANGED,
51
+ *     conference: JitsiConference
51
  *     newValue: string,
52
  *     newValue: string,
52
  *     oldValue: string
53
  *     oldValue: string
53
  * }
54
  * }

+ 4
- 0
react/features/base/participants/actions.js View File

97
         if (participant) {
97
         if (participant) {
98
             return dispatch({
98
             return dispatch({
99
                 type: PARTICIPANT_ID_CHANGED,
99
                 type: PARTICIPANT_ID_CHANGED,
100
+
101
+                // XXX A participant is identified by an id-conference pair.
102
+                // Only the local participant is with an undefined conference.
103
+                conference: undefined,
100
                 newValue: id,
104
                 newValue: id,
101
                 oldValue: participant.id
105
                 oldValue: participant.id
102
             });
106
             });

+ 16
- 4
react/features/base/participants/reducer.js View File

84
         return state.filter(p =>
84
         return state.filter(p =>
85
             !(
85
             !(
86
                 p.id === id
86
                 p.id === id
87
-                    && (p.local
88
-                        || (conference && p.conference === conference))));
87
+
88
+                    // XXX Do not allow collisions in the IDs of the local
89
+                    // participant and a remote participant cause the removal of
90
+                    // the local participant when the remote participant's
91
+                    // removal is requested.
92
+                    && p.conference === conference
93
+                    && (conference || p.local)));
89
     }
94
     }
90
     }
95
     }
91
 
96
 
111
         return (
116
         return (
112
             set(state, 'dominantSpeaker', state.id === action.participant.id));
117
             set(state, 'dominantSpeaker', state.id === action.participant.id));
113
 
118
 
114
-    case PARTICIPANT_ID_CHANGED:
115
-        if (state.id === action.oldValue) {
119
+    case PARTICIPANT_ID_CHANGED: {
120
+        // A participant is identified by an id-conference pair. Only the local
121
+        // participant is with an undefined conference.
122
+        const { conference } = action;
123
+
124
+        if (state.id === action.oldValue
125
+                && state.conference === conference
126
+                && (conference || state.local)) {
116
             return {
127
             return {
117
                 ...state,
128
                 ...state,
118
                 id: action.newValue
129
                 id: action.newValue
119
             };
130
             };
120
         }
131
         }
121
         break;
132
         break;
133
+    }
122
 
134
 
123
     case PARTICIPANT_UPDATED: {
135
     case PARTICIPANT_UPDATED: {
124
         const { participant } = action; // eslint-disable-line no-shadow
136
         const { participant } = action; // eslint-disable-line no-shadow

Loading…
Cancel
Save