您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

middleware.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { getAppProp } from '../../base/app/functions';
  2. import {
  3. CONFERENCE_JOINED,
  4. CONFERENCE_LEFT,
  5. CONFERENCE_WILL_JOIN
  6. } from '../../base/conference/actionTypes';
  7. import { PARTICIPANT_JOINED } from '../../base/participants/actionTypes';
  8. import MiddlewareRegistry from '../../base/redux/MiddlewareRegistry';
  9. import { READY_TO_CLOSE } from '../external-api/actionTypes';
  10. import { participantToParticipantInfo } from '../external-api/functions';
  11. import { isExternalAPIAvailable } from './functions';
  12. const externalAPIEnabled = isExternalAPIAvailable();
  13. /**
  14. * Check if native modules are being used or not. If not then the init of middleware doesn't happen.
  15. */
  16. !externalAPIEnabled && MiddlewareRegistry.register(store => next => action => {
  17. const result = next(action);
  18. const { type } = action;
  19. const rnSdkHandlers = getAppProp(store, 'rnSdkHandlers');
  20. switch (type) {
  21. case READY_TO_CLOSE:
  22. rnSdkHandlers.onReadyToClose && rnSdkHandlers.onReadyToClose();
  23. break;
  24. case CONFERENCE_JOINED:
  25. rnSdkHandlers.onConferenceJoined && rnSdkHandlers.onConferenceJoined();
  26. break;
  27. case CONFERENCE_WILL_JOIN:
  28. rnSdkHandlers.onConferenceWillJoin && rnSdkHandlers.onConferenceWillJoin();
  29. break;
  30. case CONFERENCE_LEFT:
  31. // Props are torn down at this point, perhaps need to leave this one out
  32. break;
  33. case PARTICIPANT_JOINED: {
  34. const { participant } = action;
  35. const participantInfo = participantToParticipantInfo(participant);
  36. rnSdkHandlers.onParticipantJoined && rnSdkHandlers.onParticipantJoined(participantInfo);
  37. break;
  38. }
  39. }
  40. return result;
  41. }
  42. );