浏览代码

fix(filmstrip): Always sort the participants alphabetically.

Reorder the sub-groups (shares, speakers and rest of the participants) always on dominant speaker changes and when participants join or leave.
master
Jaya Allamsetty 3 年前
父节点
当前提交
9013b01df6

+ 27
- 13
react/features/base/participants/reducer.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
+import { SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED } from '../../video-layout/actionTypes';
3
 import { ReducerRegistry, set } from '../redux';
4
 import { ReducerRegistry, set } from '../redux';
4
 
5
 
5
 import {
6
 import {
61
     pinnedParticipant: undefined,
62
     pinnedParticipant: undefined,
62
     remote: new Map(),
63
     remote: new Map(),
63
     sortedRemoteParticipants: new Map(),
64
     sortedRemoteParticipants: new Map(),
65
+    sortedRemoteScreenshares: new Map(),
64
     speakersList: new Map()
66
     speakersList: new Map()
65
 };
67
 };
66
 
68
 
96
     case DOMINANT_SPEAKER_CHANGED: {
98
     case DOMINANT_SPEAKER_CHANGED: {
97
         const { participant } = action;
99
         const { participant } = action;
98
         const { id, previousSpeakers = [] } = participant;
100
         const { id, previousSpeakers = [] } = participant;
99
-        const { dominantSpeaker, local, speakersList } = state;
101
+        const { dominantSpeaker, local } = state;
100
         const newSpeakers = [ id, ...previousSpeakers ];
102
         const newSpeakers = [ id, ...previousSpeakers ];
101
-        const sortedSpeakersList = Array.from(speakersList);
103
+        const sortedSpeakersList = [];
102
 
104
 
103
-        // Update the speakers list.
104
         for (const speaker of newSpeakers) {
105
         for (const speaker of newSpeakers) {
105
-            if (!state.speakersList.has(speaker) && speaker !== local?.id) {
106
+            if (speaker !== local?.id) {
106
                 const remoteParticipant = state.remote.get(speaker);
107
                 const remoteParticipant = state.remote.get(speaker);
107
 
108
 
108
                 remoteParticipant && sortedSpeakersList.push([ speaker, _getDisplayName(remoteParticipant.name) ]);
109
                 remoteParticipant && sortedSpeakersList.push([ speaker, _getDisplayName(remoteParticipant.name) ]);
109
             }
110
             }
110
         }
111
         }
111
 
112
 
112
-        // Also check if any of the existing speakers have been kicked off the list.
113
-        for (const existingSpeaker of sortedSpeakersList.keys()) {
114
-            if (!newSpeakers.find(s => s === existingSpeaker)) {
115
-                sortedSpeakersList.filter(sortedSpeaker => sortedSpeaker[0] !== existingSpeaker);
116
-            }
117
-        }
118
-
119
         // Keep the remote speaker list sorted alphabetically.
113
         // Keep the remote speaker list sorted alphabetically.
120
         sortedSpeakersList.sort((a, b) => a[1].localeCompare(b[1]));
114
         sortedSpeakersList.sort((a, b) => a[1].localeCompare(b[1]));
121
 
115
 
324
 
318
 
325
         return { ...state };
319
         return { ...state };
326
     }
320
     }
321
+    case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED: {
322
+        const { participantIds } = action;
323
+        const sortedSharesList = [];
324
+
325
+        for (const participant of participantIds) {
326
+            const remoteParticipant = state.remote.get(participant);
327
+
328
+            if (remoteParticipant) {
329
+                const displayName = _getDisplayName(remoteParticipant.name);
330
+
331
+                sortedSharesList.push([ participant, displayName ]);
332
+            }
333
+        }
334
+
335
+        // Keep the remote screen share list sorted alphabetically.
336
+        sortedSharesList.length && sortedSharesList.sort((a, b) => a[1].localeCompare(b[1]));
337
+        state.sortedRemoteScreenshares = new Map(sortedSharesList);
338
+
339
+        return { ...state };
340
+    }
327
     }
341
     }
328
 
342
 
329
     return state;
343
     return state;
335
  * @param {string} name - The display name of the participant.
349
  * @param {string} name - The display name of the participant.
336
  * @returns {string}
350
  * @returns {string}
337
  */
351
  */
338
- function _getDisplayName(name) {
352
+function _getDisplayName(name) {
339
     return name
353
     return name
340
         ?? (typeof interfaceConfig === 'object' ? interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME : 'Fellow Jitser');
354
         ?? (typeof interfaceConfig === 'object' ? interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME : 'Fellow Jitser');
341
 }
355
 }
468
  * @param {*} value - The new value.
482
  * @param {*} value - The new value.
469
  * @returns {boolean} - True if a participant was updated and false otherwise.
483
  * @returns {boolean} - True if a participant was updated and false otherwise.
470
  */
484
  */
471
- function _updateParticipantProperty(state, id, property, value) {
485
+function _updateParticipantProperty(state, id, property, value) {
472
     const { remote, local } = state;
486
     const { remote, local } = state;
473
 
487
 
474
     if (remote.has(id)) {
488
     if (remote.has(id)) {

+ 11
- 7
react/features/filmstrip/functions.any.js 查看文件

10
  * @returns {void}
10
  * @returns {void}
11
  * @private
11
  * @private
12
  */
12
  */
13
- export function updateRemoteParticipants(store: Object, participantId: ?number) {
13
+export function updateRemoteParticipants(store: Object, participantId: ?number) {
14
     const state = store.getState();
14
     const state = store.getState();
15
     const { enableThumbnailReordering = true } = state['features/base/config'];
15
     const { enableThumbnailReordering = true } = state['features/base/config'];
16
     let reorderedParticipants = [];
16
     let reorderedParticipants = [];
26
         return;
26
         return;
27
     }
27
     }
28
 
28
 
29
-    const { fakeParticipants, sortedRemoteParticipants, speakersList } = state['features/base/participants'];
30
-    const { remoteScreenShares } = state['features/video-layout'];
31
-    const screenShares = (remoteScreenShares || []).slice();
32
-    const speakers = new Map(speakersList);
29
+    const {
30
+        fakeParticipants,
31
+        sortedRemoteParticipants,
32
+        sortedRemoteScreenshares,
33
+        speakersList
34
+    } = state['features/base/participants'];
33
     const remoteParticipants = new Map(sortedRemoteParticipants);
35
     const remoteParticipants = new Map(sortedRemoteParticipants);
36
+    const screenShares = new Map(sortedRemoteScreenshares);
34
     const sharedVideos = fakeParticipants ? Array.from(fakeParticipants.keys()) : [];
37
     const sharedVideos = fakeParticipants ? Array.from(fakeParticipants.keys()) : [];
38
+    const speakers = new Map(speakersList);
35
 
39
 
36
-    for (const screenshare of screenShares) {
40
+    for (const screenshare of screenShares.keys()) {
37
         remoteParticipants.delete(screenshare);
41
         remoteParticipants.delete(screenshare);
38
         speakers.delete(screenshare);
42
         speakers.delete(screenshare);
39
     }
43
     }
47
 
51
 
48
     // Always update the order of the thumnails.
52
     // Always update the order of the thumnails.
49
     reorderedParticipants = [
53
     reorderedParticipants = [
50
-        ...screenShares.reverse(),
54
+        ...Array.from(screenShares.keys()),
51
         ...sharedVideos,
55
         ...sharedVideos,
52
         ...Array.from(speakers.keys()),
56
         ...Array.from(speakers.keys()),
53
         ...Array.from(remoteParticipants.keys())
57
         ...Array.from(remoteParticipants.keys())

+ 1
- 1
react/features/filmstrip/reducer.js 查看文件

123
             if (navigator.product !== 'ReactNative') {
123
             if (navigator.product !== 'ReactNative') {
124
                 const { visibleParticipantsStartIndex: startIndex, visibleParticipantsEndIndex: endIndex } = state;
124
                 const { visibleParticipantsStartIndex: startIndex, visibleParticipantsEndIndex: endIndex } = state;
125
 
125
 
126
-                state.visibleRemoteParticipants = new Set(state.remoteParticipants.slice(startIndex, endIndex));
126
+                state.visibleRemoteParticipants = new Set(state.remoteParticipants.slice(startIndex, endIndex + 1));
127
             }
127
             }
128
 
128
 
129
             return { ...state };
129
             return { ...state };

正在加载...
取消
保存