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.js 797B

12345678910111213141516171819202122232425262728293031
  1. // @flow
  2. import { MiddlewareRegistry } from '../../base/redux';
  3. import { getSymbolDescription } from '../../base/util';
  4. import { sendEvent } from '../external-api';
  5. import {
  6. INCOMING_CALL_ANSWERED,
  7. INCOMING_CALL_DECLINED
  8. } from './actionTypes';
  9. /**
  10. * Middleware that captures Redux actions and uses the IncomingCallExternalAPI
  11. * module to turn them into native events so the application knows about them.
  12. *
  13. * @param {Store} store - The redux store.
  14. * @returns {Function}
  15. */
  16. MiddlewareRegistry.register(store => next => action => {
  17. const result = next(action);
  18. switch (action.type) {
  19. case INCOMING_CALL_ANSWERED:
  20. case INCOMING_CALL_DECLINED:
  21. sendEvent(store, getSymbolDescription(action.type), /* data */ {});
  22. break;
  23. }
  24. return result;
  25. });