|
@@ -273,6 +273,17 @@ export function getRemoteParticipants(stateful: Object | Function) {
|
273
|
273
|
return toState(stateful)['features/base/participants'].remote;
|
274
|
274
|
}
|
275
|
275
|
|
|
276
|
+/**
|
|
277
|
+ * Selectors for the getting the remote participants in the order that they are displayed in the filmstrip.
|
|
278
|
+ *
|
|
279
|
+@param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
|
|
280
|
+ * retrieve the state features/filmstrip.
|
|
281
|
+ * @returns {Array<string>}
|
|
282
|
+ */
|
|
283
|
+export function getRemoteParticipantsSorted(stateful: Object | Function) {
|
|
284
|
+ return toState(stateful)['features/filmstrip'].remoteParticipants;
|
|
285
|
+}
|
|
286
|
+
|
276
|
287
|
/**
|
277
|
288
|
* Returns the participant which has its pinned state set to truthy.
|
278
|
289
|
*
|
|
@@ -444,67 +455,45 @@ async function _getFirstLoadableAvatarUrl(participant, store) {
|
444
|
455
|
return undefined;
|
445
|
456
|
}
|
446
|
457
|
|
447
|
|
-
|
448
|
458
|
/**
|
449
|
|
- * Selector for retrieving sorted participants by display name.
|
|
459
|
+ * Selector for retrieving ids of participants in the order that they are displayed in the filmstrip (with the
|
|
460
|
+ * exception of participants with raised hand). The participants are reordered as follows.
|
|
461
|
+ * 1. Local participant.
|
|
462
|
+ * 2. Participants with raised hand.
|
|
463
|
+ * 3. Participants with screenshare sorted alphabetically by their display name.
|
|
464
|
+ * 4. Shared video participants.
|
|
465
|
+ * 5. Recent speakers sorted alphabetically by their display name.
|
|
466
|
+ * 6. Rest of the participants sorted alphabetically by their display name.
|
450
|
467
|
*
|
451
|
468
|
* @param {(Function|Object)} stateful - The (whole) redux state, or redux's
|
452
|
|
- * {@code getState} function to be used to retrieve the state
|
453
|
|
- * features/base/participants.
|
454
|
|
- * @returns {Array<Object>}
|
|
469
|
+ * {@code getState} function to be used to retrieve the state features/base/participants.
|
|
470
|
+ * @returns {Array<string>}
|
455
|
471
|
*/
|
456
|
|
-export function getSortedParticipants(stateful: Object | Function) {
|
457
|
|
- const localParticipant = getLocalParticipant(stateful);
|
458
|
|
- const remoteParticipants = getRemoteParticipants(stateful);
|
459
|
|
- const raisedHandParticipantIds = getRaiseHandsQueue(stateful);
|
460
|
|
-
|
461
|
|
- const items = [];
|
462
|
|
- const dominantSpeaker = getDominantSpeakerParticipant(stateful);
|
463
|
|
- const raisedHandParticipants = [];
|
464
|
|
-
|
465
|
|
- raisedHandParticipantIds
|
466
|
|
- .map(id => remoteParticipants.get(id) || localParticipant)
|
467
|
|
- .forEach(p => {
|
468
|
|
- if (p !== dominantSpeaker) {
|
469
|
|
- raisedHandParticipants.push(p);
|
470
|
|
- }
|
471
|
|
- });
|
472
|
|
-
|
473
|
|
- remoteParticipants.forEach(p => {
|
474
|
|
- if (p !== dominantSpeaker && !raisedHandParticipantIds.find(id => p.id === id)) {
|
475
|
|
- items.push(p);
|
|
472
|
+export function getSortedParticipantIds(stateful: Object | Function): Array<string> {
|
|
473
|
+ const { id } = getLocalParticipant(stateful);
|
|
474
|
+ const remoteParticipants = getRemoteParticipantsSorted(stateful);
|
|
475
|
+ const reorderedParticipants = new Set(remoteParticipants);
|
|
476
|
+ const raisedHandParticipants = getRaiseHandsQueue(stateful);
|
|
477
|
+ const remoteRaisedHandParticipants = new Set(raisedHandParticipants || []);
|
|
478
|
+
|
|
479
|
+ for (const participant of remoteRaisedHandParticipants.keys()) {
|
|
480
|
+ // Avoid duplicates.
|
|
481
|
+ if (reorderedParticipants.has(participant)) {
|
|
482
|
+ reorderedParticipants.delete(participant);
|
|
483
|
+ } else {
|
|
484
|
+ remoteRaisedHandParticipants.delete(participant);
|
476
|
485
|
}
|
477
|
|
- });
|
478
|
|
-
|
479
|
|
- if (!raisedHandParticipantIds.find(id => localParticipant.id === id)) {
|
480
|
|
- items.push(localParticipant);
|
481
|
|
- }
|
482
|
|
-
|
483
|
|
- items.sort((a, b) =>
|
484
|
|
- getParticipantDisplayName(stateful, a.id).localeCompare(getParticipantDisplayName(stateful, b.id))
|
485
|
|
- );
|
486
|
|
-
|
487
|
|
- items.unshift(...raisedHandParticipants);
|
488
|
|
-
|
489
|
|
- if (dominantSpeaker && dominantSpeaker !== localParticipant) {
|
490
|
|
- items.unshift(dominantSpeaker);
|
491
|
486
|
}
|
492
|
487
|
|
493
|
|
- return items;
|
494
|
|
-}
|
495
|
|
-
|
496
|
|
-/**
|
497
|
|
- * Selector for retrieving ids of alphabetically sorted participants by name.
|
498
|
|
- *
|
499
|
|
- * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
|
500
|
|
- * {@code getState} function to be used to retrieve the state
|
501
|
|
- * features/base/participants.
|
502
|
|
- * @returns {Array<string>}
|
503
|
|
- */
|
504
|
|
-export function getSortedParticipantIds(stateful: Object | Function): Array<string> {
|
505
|
|
- const participantIds = getSortedParticipants(stateful).map((p): Object => p.id);
|
|
488
|
+ // Remove self.
|
|
489
|
+ remoteRaisedHandParticipants.has(id) && remoteRaisedHandParticipants.delete(id);
|
506
|
490
|
|
507
|
|
- return participantIds;
|
|
491
|
+ // Move self and participants with raised hand to the top of the list.
|
|
492
|
+ return [
|
|
493
|
+ id,
|
|
494
|
+ ...Array.from(remoteRaisedHandParticipants.keys()),
|
|
495
|
+ ...Array.from(reorderedParticipants.keys())
|
|
496
|
+ ];
|
508
|
497
|
}
|
509
|
498
|
|
510
|
499
|
/**
|