ソースを参照

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,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import { SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED } from '../../video-layout/actionTypes';
3 4
 import { ReducerRegistry, set } from '../redux';
4 5
 
5 6
 import {
@@ -61,6 +62,7 @@ const DEFAULT_STATE = {
61 62
     pinnedParticipant: undefined,
62 63
     remote: new Map(),
63 64
     sortedRemoteParticipants: new Map(),
65
+    sortedRemoteScreenshares: new Map(),
64 66
     speakersList: new Map()
65 67
 };
66 68
 
@@ -96,26 +98,18 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
96 98
     case DOMINANT_SPEAKER_CHANGED: {
97 99
         const { participant } = action;
98 100
         const { id, previousSpeakers = [] } = participant;
99
-        const { dominantSpeaker, local, speakersList } = state;
101
+        const { dominantSpeaker, local } = state;
100 102
         const newSpeakers = [ id, ...previousSpeakers ];
101
-        const sortedSpeakersList = Array.from(speakersList);
103
+        const sortedSpeakersList = [];
102 104
 
103
-        // Update the speakers list.
104 105
         for (const speaker of newSpeakers) {
105
-            if (!state.speakersList.has(speaker) && speaker !== local?.id) {
106
+            if (speaker !== local?.id) {
106 107
                 const remoteParticipant = state.remote.get(speaker);
107 108
 
108 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 113
         // Keep the remote speaker list sorted alphabetically.
120 114
         sortedSpeakersList.sort((a, b) => a[1].localeCompare(b[1]));
121 115
 
@@ -324,6 +318,26 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
324 318
 
325 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 343
     return state;
@@ -335,7 +349,7 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
335 349
  * @param {string} name - The display name of the participant.
336 350
  * @returns {string}
337 351
  */
338
- function _getDisplayName(name) {
352
+function _getDisplayName(name) {
339 353
     return name
340 354
         ?? (typeof interfaceConfig === 'object' ? interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME : 'Fellow Jitser');
341 355
 }
@@ -468,7 +482,7 @@ function _participantJoined({ participant }) {
468 482
  * @param {*} value - The new value.
469 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 486
     const { remote, local } = state;
473 487
 
474 488
     if (remote.has(id)) {

+ 11
- 7
react/features/filmstrip/functions.any.js ファイルの表示

@@ -10,7 +10,7 @@ import { setRemoteParticipants } from './actions';
10 10
  * @returns {void}
11 11
  * @private
12 12
  */
13
- export function updateRemoteParticipants(store: Object, participantId: ?number) {
13
+export function updateRemoteParticipants(store: Object, participantId: ?number) {
14 14
     const state = store.getState();
15 15
     const { enableThumbnailReordering = true } = state['features/base/config'];
16 16
     let reorderedParticipants = [];
@@ -26,14 +26,18 @@ import { setRemoteParticipants } from './actions';
26 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 35
     const remoteParticipants = new Map(sortedRemoteParticipants);
36
+    const screenShares = new Map(sortedRemoteScreenshares);
34 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 41
         remoteParticipants.delete(screenshare);
38 42
         speakers.delete(screenshare);
39 43
     }
@@ -47,7 +51,7 @@ import { setRemoteParticipants } from './actions';
47 51
 
48 52
     // Always update the order of the thumnails.
49 53
     reorderedParticipants = [
50
-        ...screenShares.reverse(),
54
+        ...Array.from(screenShares.keys()),
51 55
         ...sharedVideos,
52 56
         ...Array.from(speakers.keys()),
53 57
         ...Array.from(remoteParticipants.keys())

+ 1
- 1
react/features/filmstrip/reducer.js ファイルの表示

@@ -123,7 +123,7 @@ ReducerRegistry.register(
123 123
             if (navigator.product !== 'ReactNative') {
124 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 129
             return { ...state };

読み込み中…
キャンセル
保存