You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

subscriber.ts 1.7KB

1234567891011121314151617181920212223242526272829303132333435
  1. import StateListenerRegistry from '../base/redux/StateListenerRegistry';
  2. import { equals } from '../base/redux/functions';
  3. import { isFollowMeActive } from '../follow-me/functions';
  4. import { virtualScreenshareParticipantsUpdated } from './actions';
  5. import { getAutoPinSetting, updateAutoPinnedParticipant } from './functions';
  6. StateListenerRegistry.register(
  7. /* selector */ state => state['features/base/participants'].sortedRemoteVirtualScreenshareParticipants,
  8. /* listener */ (sortedRemoteVirtualScreenshareParticipants, store) => {
  9. const oldScreenSharesOrder = store.getState()['features/video-layout'].remoteScreenShares || [];
  10. const knownSharingParticipantIds = [ ...sortedRemoteVirtualScreenshareParticipants.keys() ];
  11. // Filter out any participants which are no longer screen sharing
  12. // by looping through the known sharing participants and removing any
  13. // participant IDs which are no longer sharing.
  14. const newScreenSharesOrder = oldScreenSharesOrder.filter(
  15. participantId => knownSharingParticipantIds.includes(participantId));
  16. // Make sure all new sharing participant get added to the end of the
  17. // known screen shares.
  18. knownSharingParticipantIds.forEach(participantId => {
  19. if (!newScreenSharesOrder.includes(participantId)) {
  20. newScreenSharesOrder.push(participantId);
  21. }
  22. });
  23. if (!equals(oldScreenSharesOrder, newScreenSharesOrder)) {
  24. store.dispatch(virtualScreenshareParticipantsUpdated(newScreenSharesOrder));
  25. if (getAutoPinSetting() && !isFollowMeActive(store)) {
  26. updateAutoPinnedParticipant(oldScreenSharesOrder, store);
  27. }
  28. }
  29. });