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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // @flow
  2. import { getCurrentConference } from '../base/conference';
  3. import { isLocalParticipantModerator } from '../base/participants';
  4. import { StateListenerRegistry } from '../base/redux';
  5. import { MUTE_REACTIONS_COMMAND } from './constants';
  6. /**
  7. * Subscribes to changes to the Mute Reaction Sounds setting for the local participant to
  8. * notify remote participants of current user interface status.
  9. * Changing newSelectedValue param to off, when feature is turned of so we can
  10. * notify all listeners.
  11. */
  12. StateListenerRegistry.register(
  13. /* selector */ state => state['features/base/conference'].startReactionsMuted,
  14. /* listener */ (newSelectedValue, store) => _sendMuteReactionsCommand(newSelectedValue || false, store));
  15. /**
  16. * Sends the mute-reactions command, when a local property change occurs.
  17. *
  18. * @param {*} newSelectedValue - The changed selected value from the selector.
  19. * @param {Object} store - The redux store.
  20. * @private
  21. * @returns {void}
  22. */
  23. function _sendMuteReactionsCommand(newSelectedValue, store) {
  24. const state = store.getState();
  25. const conference = getCurrentConference(state);
  26. if (!conference) {
  27. return;
  28. }
  29. // Only a moderator is allowed to send commands.
  30. if (!isLocalParticipantModerator(state)) {
  31. return;
  32. }
  33. conference.sendCommand(
  34. MUTE_REACTIONS_COMMAND,
  35. { attributes: { startReactionsMuted: Boolean(newSelectedValue) } }
  36. );
  37. }