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.

middleware.ts 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /* eslint-disable lines-around-comment */
  2. import debounce from 'lodash/debounce';
  3. import { NativeEventEmitter, NativeModules } from 'react-native';
  4. import { AnyAction } from 'redux';
  5. // @ts-expect-error
  6. import { ENDPOINT_TEXT_MESSAGE_NAME } from '../../../../modules/API/constants';
  7. import { appNavigate } from '../../app/actions.native';
  8. import { IStore } from '../../app/types';
  9. import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';
  10. import {
  11. CONFERENCE_BLURRED,
  12. CONFERENCE_FAILED,
  13. CONFERENCE_FOCUSED,
  14. CONFERENCE_JOINED,
  15. CONFERENCE_LEFT,
  16. CONFERENCE_WILL_JOIN,
  17. ENDPOINT_MESSAGE_RECEIVED,
  18. SET_ROOM
  19. } from '../../base/conference/actionTypes';
  20. import { JITSI_CONFERENCE_URL_KEY } from '../../base/conference/constants';
  21. import {
  22. forEachConference,
  23. getCurrentConference,
  24. isRoomValid
  25. } from '../../base/conference/functions';
  26. import { IJitsiConference } from '../../base/conference/reducer';
  27. import { CONNECTION_DISCONNECTED } from '../../base/connection/actionTypes';
  28. import {
  29. JITSI_CONNECTION_CONFERENCE_KEY,
  30. JITSI_CONNECTION_URL_KEY
  31. } from '../../base/connection/constants';
  32. import { getURLWithoutParams } from '../../base/connection/utils';
  33. import {
  34. JitsiConferenceEvents } from '../../base/lib-jitsi-meet';
  35. import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes';
  36. import { toggleCameraFacingMode } from '../../base/media/actions';
  37. import { MEDIA_TYPE, VIDEO_TYPE } from '../../base/media/constants';
  38. import { PARTICIPANT_JOINED, PARTICIPANT_LEFT } from '../../base/participants/actionTypes';
  39. import {
  40. getLocalParticipant,
  41. getParticipantById,
  42. getRemoteParticipants,
  43. isScreenShareParticipantById
  44. } from '../../base/participants/functions';
  45. import MiddlewareRegistry from '../../base/redux/MiddlewareRegistry';
  46. import StateListenerRegistry from '../../base/redux/StateListenerRegistry';
  47. import { toggleScreensharing } from '../../base/tracks/actions.native';
  48. import { getLocalTracks, isLocalTrackMuted } from '../../base/tracks/functions.native';
  49. import { ITrack } from '../../base/tracks/types';
  50. import { CLOSE_CHAT, OPEN_CHAT } from '../../chat/actionTypes';
  51. import { closeChat, openChat, sendMessage, setPrivateMessageRecipient } from '../../chat/actions.native';
  52. import { setRequestingSubtitles } from '../../subtitles/actions.any';
  53. import { muteLocal } from '../../video-menu/actions.native';
  54. import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture/actionTypes';
  55. // @ts-ignore
  56. import { isExternalAPIAvailable } from '../react-native-sdk/functions';
  57. import {
  58. CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED,
  59. READY_TO_CLOSE
  60. } from './actionTypes';
  61. import { setParticipantsWithScreenShare } from './actions';
  62. import { participantToParticipantInfo, sendEvent } from './functions';
  63. import logger from './logger';
  64. /**
  65. * Event which will be emitted on the native side when a chat message is received
  66. * through the channel.
  67. */
  68. const CHAT_MESSAGE_RECEIVED = 'CHAT_MESSAGE_RECEIVED';
  69. /**
  70. * Event which will be emitted on the native side when the chat dialog is displayed/closed.
  71. */
  72. const CHAT_TOGGLED = 'CHAT_TOGGLED';
  73. /**
  74. * Event which will be emitted on the native side to indicate the conference
  75. * has ended either by user request or because an error was produced.
  76. */
  77. const CONFERENCE_TERMINATED = 'CONFERENCE_TERMINATED';
  78. /**
  79. * Event which will be emitted on the native side to indicate that the custom overflow menu button was pressed.
  80. */
  81. const CUSTOM_MENU_BUTTON_PRESSED = 'CUSTOM_MENU_BUTTON_PRESSED';
  82. /**
  83. * Event which will be emitted on the native side to indicate a message was received
  84. * through the channel.
  85. */
  86. const ENDPOINT_TEXT_MESSAGE_RECEIVED = 'ENDPOINT_TEXT_MESSAGE_RECEIVED';
  87. /**
  88. * Event which will be emitted on the native side to indicate a participant toggles
  89. * the screen share.
  90. */
  91. const SCREEN_SHARE_TOGGLED = 'SCREEN_SHARE_TOGGLED';
  92. /**
  93. * Event which will be emitted on the native side with the participant info array.
  94. */
  95. const PARTICIPANTS_INFO_RETRIEVED = 'PARTICIPANTS_INFO_RETRIEVED';
  96. const externalAPIEnabled = isExternalAPIAvailable();
  97. let eventEmitter: any;
  98. const { ExternalAPI } = NativeModules;
  99. if (externalAPIEnabled) {
  100. eventEmitter = new NativeEventEmitter(ExternalAPI);
  101. }
  102. /**
  103. * Middleware that captures Redux actions and uses the ExternalAPI module to
  104. * turn them into native events so the application knows about them.
  105. *
  106. * @param {Store} store - Redux store.
  107. * @returns {Function}
  108. */
  109. externalAPIEnabled && MiddlewareRegistry.register(store => next => action => {
  110. const oldAudioMuted = store.getState()['features/base/media'].audio.muted;
  111. const result = next(action);
  112. const { type } = action;
  113. switch (type) {
  114. case APP_WILL_MOUNT:
  115. _registerForNativeEvents(store);
  116. break;
  117. case APP_WILL_UNMOUNT:
  118. _unregisterForNativeEvents();
  119. break;
  120. case CONFERENCE_FAILED: {
  121. const { error, ...data } = action;
  122. // XXX Certain CONFERENCE_FAILED errors are recoverable i.e. they have
  123. // prevented the user from joining a specific conference but the app may
  124. // be able to eventually join the conference. For example, the app will
  125. // ask the user for a password upon
  126. // JitsiConferenceErrors.PASSWORD_REQUIRED and will retry joining the
  127. // conference afterwards. Such errors are to not reach the native
  128. // counterpart of the External API (or at least not in the
  129. // fatality/finality semantics attributed to
  130. // conferenceFailed:/onConferenceFailed).
  131. if (!error.recoverable) {
  132. _sendConferenceEvent(store, /* action */ {
  133. error: _toErrorString(error),
  134. ...data
  135. });
  136. }
  137. break;
  138. }
  139. case CONFERENCE_LEFT:
  140. _sendConferenceEvent(store, action);
  141. break;
  142. case CONFERENCE_JOINED:
  143. _sendConferenceEvent(store, action);
  144. _registerForEndpointTextMessages(store);
  145. break;
  146. case CONFERENCE_BLURRED:
  147. sendEvent(store, CONFERENCE_BLURRED, {});
  148. break;
  149. case CONFERENCE_FOCUSED:
  150. sendEvent(store, CONFERENCE_FOCUSED, {});
  151. break;
  152. case CONNECTION_DISCONNECTED: {
  153. // FIXME: This is a hack. See the description in the JITSI_CONNECTION_CONFERENCE_KEY constant definition.
  154. // Check if this connection was attached to any conference.
  155. // If it wasn't, fake a CONFERENCE_TERMINATED event.
  156. const { connection } = action;
  157. const conference = connection[JITSI_CONNECTION_CONFERENCE_KEY];
  158. if (!conference) {
  159. // This action will arrive late, so the locationURL stored on the state is no longer valid.
  160. const locationURL = connection[JITSI_CONNECTION_URL_KEY];
  161. sendEvent(
  162. store,
  163. CONFERENCE_TERMINATED,
  164. /* data */ {
  165. url: _normalizeUrl(locationURL)
  166. });
  167. }
  168. break;
  169. }
  170. case CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED: {
  171. const { id, text } = action;
  172. sendEvent(
  173. store,
  174. CUSTOM_MENU_BUTTON_PRESSED,
  175. {
  176. id,
  177. text
  178. });
  179. break;
  180. }
  181. case ENDPOINT_MESSAGE_RECEIVED: {
  182. const { participant, data } = action;
  183. if (data?.name === ENDPOINT_TEXT_MESSAGE_NAME) {
  184. sendEvent(
  185. store,
  186. ENDPOINT_TEXT_MESSAGE_RECEIVED,
  187. /* data */ {
  188. message: data.text,
  189. senderId: participant.getId()
  190. });
  191. }
  192. break;
  193. }
  194. case ENTER_PICTURE_IN_PICTURE:
  195. sendEvent(store, type, /* data */ {});
  196. break;
  197. case OPEN_CHAT:
  198. case CLOSE_CHAT: {
  199. sendEvent(
  200. store,
  201. CHAT_TOGGLED,
  202. /* data */ {
  203. isOpen: action.type === OPEN_CHAT
  204. });
  205. break;
  206. }
  207. case PARTICIPANT_JOINED:
  208. case PARTICIPANT_LEFT: {
  209. // Skip these events while not in a conference. SDK users can still retrieve them.
  210. const { conference } = store.getState()['features/base/conference'];
  211. if (!conference) {
  212. break;
  213. }
  214. const { participant } = action;
  215. const isVirtualScreenshareParticipant = isScreenShareParticipantById(store.getState(), participant.id);
  216. if (isVirtualScreenshareParticipant) {
  217. break;
  218. }
  219. sendEvent(
  220. store,
  221. action.type,
  222. participantToParticipantInfo(participant) /* data */
  223. );
  224. break;
  225. }
  226. case READY_TO_CLOSE:
  227. sendEvent(store, type, /* data */ {});
  228. break;
  229. case SET_ROOM:
  230. _maybeTriggerEarlyConferenceWillJoin(store, action);
  231. break;
  232. case SET_AUDIO_MUTED:
  233. if (action.muted !== oldAudioMuted) {
  234. sendEvent(
  235. store,
  236. 'AUDIO_MUTED_CHANGED',
  237. /* data */ {
  238. muted: action.muted
  239. });
  240. }
  241. break;
  242. case SET_VIDEO_MUTED:
  243. sendEvent(
  244. store,
  245. 'VIDEO_MUTED_CHANGED',
  246. /* data */ {
  247. muted: action.muted
  248. });
  249. break;
  250. }
  251. return result;
  252. });
  253. /**
  254. * Listen for changes to the known media tracks and look
  255. * for updates to screen shares for emitting native events.
  256. * The listener is debounced to avoid state thrashing that might occur,
  257. * especially when switching in or out of p2p.
  258. */
  259. externalAPIEnabled && StateListenerRegistry.register(
  260. /* selector */ state => state['features/base/tracks'],
  261. /* listener */ debounce((tracks: ITrack[], store: IStore) => {
  262. const oldScreenShares = store.getState()['features/mobile/external-api'].screenShares || [];
  263. const newScreenShares = tracks
  264. .filter(track => track.mediaType === MEDIA_TYPE.SCREENSHARE || track.videoType === VIDEO_TYPE.DESKTOP)
  265. .map(track => track.participantId);
  266. oldScreenShares.forEach(participantId => {
  267. if (!newScreenShares.includes(participantId)) {
  268. sendEvent(
  269. store,
  270. SCREEN_SHARE_TOGGLED,
  271. /* data */ {
  272. participantId,
  273. sharing: false
  274. });
  275. }
  276. });
  277. newScreenShares.forEach(participantId => {
  278. if (!oldScreenShares.includes(participantId)) {
  279. sendEvent(
  280. store,
  281. SCREEN_SHARE_TOGGLED,
  282. /* data */ {
  283. participantId,
  284. sharing: true
  285. });
  286. }
  287. });
  288. store.dispatch(setParticipantsWithScreenShare(newScreenShares));
  289. }, 100));
  290. /**
  291. * Registers for events sent from the native side via NativeEventEmitter.
  292. *
  293. * @param {Store} store - The redux store.
  294. * @private
  295. * @returns {void}
  296. */
  297. function _registerForNativeEvents(store: IStore) {
  298. const { getState, dispatch } = store;
  299. eventEmitter.addListener(ExternalAPI.HANG_UP, () => {
  300. dispatch(appNavigate(undefined));
  301. });
  302. eventEmitter.addListener(ExternalAPI.SET_AUDIO_MUTED, ({ muted }: any) => {
  303. dispatch(muteLocal(muted, MEDIA_TYPE.AUDIO));
  304. });
  305. eventEmitter.addListener(ExternalAPI.SET_VIDEO_MUTED, ({ muted }: any) => {
  306. dispatch(muteLocal(muted, MEDIA_TYPE.VIDEO));
  307. });
  308. eventEmitter.addListener(ExternalAPI.SEND_ENDPOINT_TEXT_MESSAGE, ({ to, message }: any) => {
  309. const conference = getCurrentConference(getState());
  310. try {
  311. conference?.sendEndpointMessage(to, {
  312. name: ENDPOINT_TEXT_MESSAGE_NAME,
  313. text: message
  314. });
  315. } catch (error) {
  316. logger.warn('Cannot send endpointMessage', error);
  317. }
  318. });
  319. eventEmitter.addListener(ExternalAPI.TOGGLE_SCREEN_SHARE, ({ enabled }: any) => {
  320. dispatch(toggleScreensharing(enabled));
  321. });
  322. eventEmitter.addListener(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO, ({ requestId }: any) => {
  323. const participantsInfo = [];
  324. const remoteParticipants = getRemoteParticipants(store);
  325. const localParticipant = getLocalParticipant(store);
  326. localParticipant && participantsInfo.push(participantToParticipantInfo(localParticipant));
  327. remoteParticipants.forEach(participant => {
  328. if (!participant.fakeParticipant) {
  329. participantsInfo.push(participantToParticipantInfo(participant));
  330. }
  331. });
  332. sendEvent(
  333. store,
  334. PARTICIPANTS_INFO_RETRIEVED,
  335. /* data */ {
  336. participantsInfo,
  337. requestId
  338. });
  339. });
  340. eventEmitter.addListener(ExternalAPI.OPEN_CHAT, ({ to }: any) => {
  341. const participant = getParticipantById(store, to);
  342. dispatch(openChat(participant));
  343. });
  344. eventEmitter.addListener(ExternalAPI.CLOSE_CHAT, () => {
  345. dispatch(closeChat());
  346. });
  347. eventEmitter.addListener(ExternalAPI.SEND_CHAT_MESSAGE, ({ message, to }: any) => {
  348. const participant = getParticipantById(store, to);
  349. if (participant) {
  350. dispatch(setPrivateMessageRecipient(participant));
  351. }
  352. dispatch(sendMessage(message));
  353. });
  354. eventEmitter.addListener(ExternalAPI.SET_CLOSED_CAPTIONS_ENABLED,
  355. ({ enabled, displaySubtitles, language }: any) => {
  356. dispatch(setRequestingSubtitles(enabled, displaySubtitles, language));
  357. });
  358. eventEmitter.addListener(ExternalAPI.TOGGLE_CAMERA, () => {
  359. dispatch(toggleCameraFacingMode());
  360. });
  361. }
  362. /**
  363. * Unregister for events sent from the native side via NativeEventEmitter.
  364. *
  365. * @private
  366. * @returns {void}
  367. */
  368. function _unregisterForNativeEvents() {
  369. eventEmitter.removeAllListeners(ExternalAPI.HANG_UP);
  370. eventEmitter.removeAllListeners(ExternalAPI.SET_AUDIO_MUTED);
  371. eventEmitter.removeAllListeners(ExternalAPI.SET_VIDEO_MUTED);
  372. eventEmitter.removeAllListeners(ExternalAPI.SEND_ENDPOINT_TEXT_MESSAGE);
  373. eventEmitter.removeAllListeners(ExternalAPI.TOGGLE_SCREEN_SHARE);
  374. eventEmitter.removeAllListeners(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO);
  375. eventEmitter.removeAllListeners(ExternalAPI.OPEN_CHAT);
  376. eventEmitter.removeAllListeners(ExternalAPI.CLOSE_CHAT);
  377. eventEmitter.removeAllListeners(ExternalAPI.SEND_CHAT_MESSAGE);
  378. eventEmitter.removeAllListeners(ExternalAPI.SET_CLOSED_CAPTIONS_ENABLED);
  379. eventEmitter.removeAllListeners(ExternalAPI.TOGGLE_CAMERA);
  380. }
  381. /**
  382. * Registers for endpoint messages sent on conference data channel.
  383. *
  384. * @param {Store} store - The redux store.
  385. * @private
  386. * @returns {void}
  387. */
  388. function _registerForEndpointTextMessages(store: IStore) {
  389. const conference = getCurrentConference(store.getState());
  390. conference?.on(
  391. JitsiConferenceEvents.MESSAGE_RECEIVED,
  392. (id: string, message: string, timestamp: number) => {
  393. sendEvent(
  394. store,
  395. CHAT_MESSAGE_RECEIVED,
  396. /* data */ {
  397. senderId: id,
  398. message,
  399. isPrivate: false,
  400. timestamp
  401. });
  402. }
  403. );
  404. conference?.on(
  405. JitsiConferenceEvents.PRIVATE_MESSAGE_RECEIVED,
  406. (id: string, message: string, timestamp: number) => {
  407. sendEvent(
  408. store,
  409. CHAT_MESSAGE_RECEIVED,
  410. /* data */ {
  411. senderId: id,
  412. message,
  413. isPrivate: true,
  414. timestamp
  415. });
  416. }
  417. );
  418. }
  419. /**
  420. * Returns a {@code String} representation of a specific error {@code Object}.
  421. *
  422. * @param {Error|Object|string} error - The error {@code Object} to return a
  423. * {@code String} representation of.
  424. * @returns {string} A {@code String} representation of the specified
  425. * {@code error}.
  426. */
  427. function _toErrorString(
  428. error: Error | { message?: string; name?: string; } | string) {
  429. // XXX In lib-jitsi-meet and jitsi-meet we utilize errors in the form of
  430. // strings, Error instances, and plain objects which resemble Error.
  431. return (
  432. error
  433. ? typeof error === 'string'
  434. ? error
  435. : Error.prototype.toString.apply(error)
  436. : '');
  437. }
  438. /**
  439. * If {@link SET_ROOM} action happens for a valid conference room this method
  440. * will emit an early {@link CONFERENCE_WILL_JOIN} event to let the external API
  441. * know that a conference is being joined. Before that happens a connection must
  442. * be created and only then base/conference feature would emit
  443. * {@link CONFERENCE_WILL_JOIN}. That is fine for the Jitsi Meet app, because
  444. * that's the a conference instance gets created, but it's too late for
  445. * the external API to learn that. The latter {@link CONFERENCE_WILL_JOIN} is
  446. * swallowed in {@link _swallowEvent}.
  447. *
  448. * @param {Store} store - The redux store.
  449. * @param {Action} action - The redux action.
  450. * @returns {void}
  451. */
  452. function _maybeTriggerEarlyConferenceWillJoin(store: IStore, action: AnyAction) {
  453. const { locationURL } = store.getState()['features/base/connection'];
  454. const { room } = action;
  455. isRoomValid(room) && locationURL && sendEvent(
  456. store,
  457. CONFERENCE_WILL_JOIN,
  458. /* data */ {
  459. url: _normalizeUrl(locationURL)
  460. });
  461. }
  462. /**
  463. * Normalizes the given URL for presentation over the external API.
  464. *
  465. * @param {URL} url -The URL to normalize.
  466. * @returns {string} - The normalized URL as a string.
  467. */
  468. function _normalizeUrl(url: URL) {
  469. return getURLWithoutParams(url).href;
  470. }
  471. /**
  472. * Sends an event to the native counterpart of the External API for a specific
  473. * conference-related redux action.
  474. *
  475. * @param {Store} store - The redux store.
  476. * @param {Action} action - The redux action.
  477. * @returns {void}
  478. */
  479. function _sendConferenceEvent(
  480. store: IStore,
  481. action: {
  482. conference: IJitsiConference;
  483. isAudioMuted?: boolean;
  484. type: string;
  485. url?: string;
  486. }) {
  487. const { conference, type, ...data } = action;
  488. // For these (redux) actions, conference identifies a JitsiConference
  489. // instance. The external API cannot transport such an object so we have to
  490. // transport an "equivalent".
  491. if (conference) { // @ts-ignore
  492. data.url = _normalizeUrl(conference[JITSI_CONFERENCE_URL_KEY]);
  493. const localTracks = getLocalTracks(store.getState()['features/base/tracks']);
  494. const isAudioMuted = isLocalTrackMuted(localTracks, MEDIA_TYPE.AUDIO);
  495. data.isAudioMuted = isAudioMuted;
  496. }
  497. if (_swallowEvent(store, action, data)) {
  498. return;
  499. }
  500. let type_;
  501. switch (type) {
  502. case CONFERENCE_FAILED:
  503. case CONFERENCE_LEFT:
  504. type_ = CONFERENCE_TERMINATED;
  505. break;
  506. default:
  507. type_ = type;
  508. break;
  509. }
  510. sendEvent(store, type_, data);
  511. }
  512. /**
  513. * Determines whether to not send a {@code CONFERENCE_LEFT} event to the native
  514. * counterpart of the External API.
  515. *
  516. * @param {Object} store - The redux store.
  517. * @param {Action} action - The redux action which is causing the sending of the
  518. * event.
  519. * @param {Object} data - The details/specifics of the event to send determined
  520. * by/associated with the specified {@code action}.
  521. * @returns {boolean} If the specified event is to not be sent, {@code true};
  522. * otherwise, {@code false}.
  523. */
  524. function _swallowConferenceLeft({ getState }: IStore, action: AnyAction, { url }: { url: string; }) {
  525. // XXX Internally, we work with JitsiConference instances. Externally
  526. // though, we deal with URL strings. The relation between the two is many to
  527. // one so it's technically and practically possible (by externally loading
  528. // the same URL string multiple times) to try to send CONFERENCE_LEFT
  529. // externally for a URL string which identifies a JitsiConference that the
  530. // app is internally legitimately working with.
  531. let swallowConferenceLeft = false;
  532. url
  533. && forEachConference(getState, (conference, conferenceURL) => {
  534. if (conferenceURL && conferenceURL.toString() === url) {
  535. swallowConferenceLeft = true;
  536. }
  537. return !swallowConferenceLeft;
  538. });
  539. return swallowConferenceLeft;
  540. }
  541. /**
  542. * Determines whether to not send a specific event to the native counterpart of
  543. * the External API.
  544. *
  545. * @param {Object} store - The redux store.
  546. * @param {Action} action - The redux action which is causing the sending of the
  547. * event.
  548. * @param {Object} data - The details/specifics of the event to send determined
  549. * by/associated with the specified {@code action}.
  550. * @returns {boolean} If the specified event is to not be sent, {@code true};
  551. * otherwise, {@code false}.
  552. */
  553. function _swallowEvent(store: IStore, action: AnyAction, data: any) {
  554. switch (action.type) {
  555. case CONFERENCE_LEFT:
  556. return _swallowConferenceLeft(store, action, data);
  557. default:
  558. return false;
  559. }
  560. }