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.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // @flow
  2. import { getLocalParticipant } from '../base/participants';
  3. import { StateListenerRegistry } from '../base/redux';
  4. import { appendSuffix } from '../display-name';
  5. import { shouldDisplayTileView } from '../video-layout';
  6. declare var APP: Object;
  7. declare var interfaceConfig: Object;
  8. /**
  9. * StateListenerRegistry provides a reliable way of detecting changes to
  10. * preferred layout state and dispatching additional actions.
  11. */
  12. StateListenerRegistry.register(
  13. /* selector */ state => shouldDisplayTileView(state),
  14. /* listener */ displayTileView => {
  15. APP.API.notifyTileViewChanged(displayTileView);
  16. });
  17. StateListenerRegistry.register(
  18. /* selector */ state => state['features/base/settings'].displayName,
  19. /* listener */ (displayName, store) => {
  20. const localParticipant = getLocalParticipant(store.getState());
  21. // Initial setting of the display name occurs happens on app
  22. // initialization, before the local participant is ready. The initial
  23. // settings is not desired to be fired anyways, only changes.
  24. if (localParticipant) {
  25. const { id } = localParticipant;
  26. APP.API.notifyDisplayNameChanged(id, {
  27. displayName,
  28. formattedDisplayName: appendSuffix(
  29. displayName,
  30. interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME)
  31. });
  32. }
  33. });
  34. /**
  35. * Updates the on stage participant value.
  36. */
  37. StateListenerRegistry.register(
  38. /* selector */ state => state['features/large-video'].participantId,
  39. /* listener */ participantId => {
  40. APP.API.notifyOnStageParticipantChanged(participantId);
  41. }
  42. );