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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. /**
  8. * StateListenerRegistry provides a reliable way of detecting changes to
  9. * preferred layout state and dispatching additional actions.
  10. */
  11. StateListenerRegistry.register(
  12. /* selector */ state => shouldDisplayTileView(state),
  13. /* listener */ displayTileView => {
  14. APP.API.notifyTileViewChanged(displayTileView);
  15. });
  16. StateListenerRegistry.register(
  17. /* selector */ state => state['features/base/settings'].displayName,
  18. /* listener */ (displayName, store) => {
  19. const localParticipant = getLocalParticipant(store.getState());
  20. const { defaultLocalDisplayName } = store.getState()['features/base/config'];
  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. defaultLocalDisplayName
  31. )
  32. });
  33. }
  34. });
  35. /**
  36. * Updates the on stage participant value.
  37. */
  38. StateListenerRegistry.register(
  39. /* selector */ state => state['features/large-video'].participantId,
  40. /* listener */ participantId => {
  41. APP.API.notifyOnStageParticipantChanged(participantId);
  42. }
  43. );