Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

functions.any.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 { enableThumbnailReordering = true } = state['features/base/config'];
  14. let reorderedParticipants = [];
  15. if (!enableThumbnailReordering) {
  16. if (participantId) {
  17. const { remoteParticipants } = state['features/filmstrip'];
  18. reorderedParticipants = [ ...remoteParticipants, participantId ];
  19. store.dispatch(setRemoteParticipants(reorderedParticipants));
  20. }
  21. return;
  22. }
  23. const { fakeParticipants, sortedRemoteParticipants, speakersList } = state['features/base/participants'];
  24. const { remoteScreenShares } = state['features/video-layout'];
  25. const screenShares = (remoteScreenShares || []).slice();
  26. const speakers = new Map(speakersList);
  27. const remoteParticipants = new Map(sortedRemoteParticipants);
  28. const sharedVideos = fakeParticipants ? Array.from(fakeParticipants.keys()) : [];
  29. for (const screenshare of screenShares) {
  30. remoteParticipants.delete(screenshare);
  31. speakers.delete(screenshare);
  32. }
  33. for (const sharedVideo of sharedVideos) {
  34. remoteParticipants.delete(sharedVideo);
  35. speakers.delete(sharedVideo);
  36. }
  37. for (const speaker of speakers.keys()) {
  38. remoteParticipants.delete(speaker);
  39. }
  40. // Always update the order of the thumnails.
  41. reorderedParticipants = [
  42. ...screenShares.reverse(),
  43. ...sharedVideos,
  44. ...Array.from(speakers.keys()),
  45. ...Array.from(remoteParticipants.keys())
  46. ];
  47. store.dispatch(setRemoteParticipants(reorderedParticipants));
  48. }
  49. /**
  50. * Private helper to calculate the reordered list of remote participants when a participant leaves.
  51. *
  52. * @param {*} store - The redux store.
  53. * @param {string} participantId - The endpoint id of the participant leaving the call.
  54. * @returns {void}
  55. * @private
  56. */
  57. export function updateRemoteParticipantsOnLeave(store: Object, participantId: ?string = null) {
  58. if (!participantId) {
  59. return;
  60. }
  61. const state = store.getState();
  62. const { remoteParticipants } = state['features/filmstrip'];
  63. const reorderedParticipants = new Set(remoteParticipants);
  64. reorderedParticipants.delete(participantId)
  65. && store.dispatch(setRemoteParticipants(Array.from(reorderedParticipants)));
  66. }