選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

middleware.js 2.2KB

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