您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.any.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @flow
  2. import { setRemoteParticipants } from './actions';
  3. /**
  4. * Computes the reorderd list of the remote participants.
  5. *
  6. * @param {*} store - The redux store.
  7. * @param {string} participantId - The endpoint id of the participant that joined the call.
  8. * @returns {void}
  9. * @private
  10. */
  11. export function updateRemoteParticipants(store: Object, participantId: ?number) {
  12. const state = store.getState();
  13. const { testing = {} } = state['features/base/config'];
  14. const enableThumbnailReordering = testing.enableThumbnailReordering ?? true;
  15. let reorderedParticipants = [];
  16. if (!enableThumbnailReordering) {
  17. if (participantId) {
  18. const { remoteParticipants } = state['features/filmstrip'];
  19. reorderedParticipants = [ ...remoteParticipants, participantId ];
  20. store.dispatch(setRemoteParticipants(reorderedParticipants));
  21. }
  22. return;
  23. }
  24. const {
  25. fakeParticipants,
  26. sortedRemoteParticipants,
  27. sortedRemoteScreenshares,
  28. speakersList
  29. } = state['features/base/participants'];
  30. const remoteParticipants = new Map(sortedRemoteParticipants);
  31. const screenShares = new Map(sortedRemoteScreenshares);
  32. const sharedVideos = fakeParticipants ? Array.from(fakeParticipants.keys()) : [];
  33. const speakers = new Map(speakersList);
  34. for (const screenshare of screenShares.keys()) {
  35. remoteParticipants.delete(screenshare);
  36. speakers.delete(screenshare);
  37. }
  38. for (const sharedVideo of sharedVideos) {
  39. remoteParticipants.delete(sharedVideo);
  40. speakers.delete(sharedVideo);
  41. }
  42. for (const speaker of speakers.keys()) {
  43. remoteParticipants.delete(speaker);
  44. }
  45. // Always update the order of the thumnails.
  46. reorderedParticipants = [
  47. ...Array.from(screenShares.keys()),
  48. ...sharedVideos,
  49. ...Array.from(speakers.keys()),
  50. ...Array.from(remoteParticipants.keys())
  51. ];
  52. store.dispatch(setRemoteParticipants(reorderedParticipants));
  53. }
  54. /**
  55. * Private helper to calculate the reordered list of remote participants when a participant leaves.
  56. *
  57. * @param {*} store - The redux store.
  58. * @param {string} participantId - The endpoint id of the participant leaving the call.
  59. * @returns {void}
  60. * @private
  61. */
  62. export function updateRemoteParticipantsOnLeave(store: Object, participantId: ?string = null) {
  63. if (!participantId) {
  64. return;
  65. }
  66. const state = store.getState();
  67. const { remoteParticipants } = state['features/filmstrip'];
  68. const reorderedParticipants = new Set(remoteParticipants);
  69. reorderedParticipants.delete(participantId)
  70. && store.dispatch(setRemoteParticipants(Array.from(reorderedParticipants)));
  71. }