Quellcode durchsuchen

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 vor 7 Jahren
Ursprung
Commit
c672ffd435

+ 1
- 0
react/features/base/participants/actionTypes.js Datei anzeigen

@@ -48,6 +48,7 @@ export const PARTICIPANT_DISPLAY_NAME_CHANGED
48 48
  *
49 49
  * {
50 50
  *     type: PARTICIPANT_ID_CHANGED,
51
+ *     conference: JitsiConference
51 52
  *     newValue: string,
52 53
  *     oldValue: string
53 54
  * }

+ 4
- 0
react/features/base/participants/actions.js Datei anzeigen

@@ -97,6 +97,10 @@ export function localParticipantIdChanged(id) {
97 97
         if (participant) {
98 98
             return dispatch({
99 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 104
                 newValue: id,
101 105
                 oldValue: participant.id
102 106
             });

+ 16
- 4
react/features/base/participants/reducer.js Datei anzeigen

@@ -84,8 +84,13 @@ ReducerRegistry.register('features/base/participants', (state = [], action) => {
84 84
         return state.filter(p =>
85 85
             !(
86 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,14 +116,21 @@ function _participant(state: Object = {}, action) {
111 116
         return (
112 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 127
             return {
117 128
                 ...state,
118 129
                 id: action.newValue
119 130
             };
120 131
         }
121 132
         break;
133
+    }
122 134
 
123 135
     case PARTICIPANT_UPDATED: {
124 136
         const { participant } = action; // eslint-disable-line no-shadow

Laden…
Abbrechen
Speichern