Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

middleware.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @flow
  2. import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
  3. import { CONFERENCE_JOINED } from '../base/conference';
  4. import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
  5. import { setAudioMuted } from '../base/media';
  6. import { MiddlewareRegistry } from '../base/redux';
  7. import { playSound, registerSound, unregisterSound } from '../base/sounds';
  8. import {
  9. hideNotification,
  10. showNotification
  11. } from '../notifications';
  12. import { setCurrentNotificationUid } from './actions';
  13. import { TALK_WHILE_MUTED_SOUND_ID } from './constants';
  14. import { TALK_WHILE_MUTED_SOUND_FILE } from './sounds';
  15. MiddlewareRegistry.register(store => next => action => {
  16. const result = next(action);
  17. const { dispatch, getState } = store;
  18. const { conference } = action;
  19. switch (action.type) {
  20. case APP_WILL_MOUNT:
  21. dispatch(registerSound(TALK_WHILE_MUTED_SOUND_ID, TALK_WHILE_MUTED_SOUND_FILE));
  22. break;
  23. case APP_WILL_UNMOUNT:
  24. dispatch(unregisterSound(TALK_WHILE_MUTED_SOUND_ID));
  25. break;
  26. case CONFERENCE_JOINED: {
  27. conference.on(
  28. JitsiConferenceEvents.TRACK_MUTE_CHANGED,
  29. track => {
  30. const { currentNotificationUid } = getState()['features/talk-while-muted'];
  31. if (currentNotificationUid && track.isAudioTrack() && track.isLocal() && !track.isMuted()) {
  32. dispatch(hideNotification(currentNotificationUid));
  33. dispatch(setCurrentNotificationUid());
  34. }
  35. });
  36. conference.on(
  37. JitsiConferenceEvents.TALK_WHILE_MUTED, async () => {
  38. const notification = await dispatch(showNotification({
  39. titleKey: 'toolbar.talkWhileMutedPopup',
  40. customActionNameKey: 'notify.unmute',
  41. customActionHandler: () => dispatch(setAudioMuted(false))
  42. }));
  43. const { soundsTalkWhileMuted } = getState()['features/base/settings'];
  44. if (soundsTalkWhileMuted) {
  45. dispatch(playSound(TALK_WHILE_MUTED_SOUND_ID));
  46. }
  47. if (notification) {
  48. // we store the last start muted notification id that we showed,
  49. // so we can hide it when unmuted mic is detected
  50. dispatch(setCurrentNotificationUid(notification.uid));
  51. }
  52. });
  53. break;
  54. }
  55. }
  56. return result;
  57. });