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 865B

123456789101112131415161718192021222324252627282930313233343536
  1. import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
  2. import { MiddlewareRegistry } from '../base/redux';
  3. import { SET_BILLING_ID } from './actionTypes';
  4. import { countEndpoint } from './actions';
  5. import { setBillingId } from './functions';
  6. /**
  7. * The redux middleware for billing counter.
  8. *
  9. * @param {Store} store - The redux store.
  10. * @returns {Function}
  11. */
  12. MiddlewareRegistry.register(store => next => async action => {
  13. switch (action.type) {
  14. case SET_BILLING_ID: {
  15. setBillingId(action.value);
  16. break;
  17. }
  18. case PARTICIPANT_JOINED: {
  19. const shouldCount = !store.getState()['features/billing-counter'].endpointCounted
  20. && !action.participant.local;
  21. if (shouldCount) {
  22. store.dispatch(countEndpoint());
  23. }
  24. break;
  25. }
  26. }
  27. return next(action);
  28. });