2018-07-15 14:50:38 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
|
|
|
|
|
|
import { sendEvent } from '../external-api';
|
|
|
|
|
2018-07-16 16:36:32 +00:00
|
|
|
import { INCOMING_CALL_ANSWERED, INCOMING_CALL_DECLINED } from './actionTypes';
|
2018-07-15 14:50:38 +00:00
|
|
|
|
|
|
|
/**
|
2018-07-16 16:36:32 +00:00
|
|
|
* Middleware that captures redux actions and uses the ExternalAPI module to
|
|
|
|
* turn them into native events so the app knows about them.
|
2018-07-15 14:50:38 +00:00
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case INCOMING_CALL_ANSWERED:
|
|
|
|
case INCOMING_CALL_DECLINED:
|
2019-03-19 12:34:05 +00:00
|
|
|
sendEvent(store, action.type, /* data */ {});
|
2018-07-15 14:50:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|