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 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // @flow
  2. import {
  3. CONFERENCE_FAILED,
  4. CONFERENCE_JOINED,
  5. KICKED_OUT
  6. } from '../base/conference';
  7. import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
  8. import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
  9. import {
  10. PARTICIPANT_KICKED,
  11. getAvatarURLByParticipantId,
  12. getLocalParticipant
  13. } from '../base/participants';
  14. import { MiddlewareRegistry } from '../base/redux';
  15. import { appendSuffix } from '../display-name';
  16. import { SUBMIT_FEEDBACK } from '../feedback';
  17. import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
  18. declare var APP: Object;
  19. declare var interfaceConfig: Object;
  20. /**
  21. * The middleware of the feature {@code external-api}.
  22. *
  23. * @returns {Function}
  24. */
  25. MiddlewareRegistry.register(store => next => action => {
  26. const result = next(action);
  27. switch (action.type) {
  28. case CONFERENCE_FAILED: {
  29. if (action.conference
  30. && action.error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) {
  31. APP.API.notifyOnPasswordRequired();
  32. }
  33. break;
  34. }
  35. case CONFERENCE_JOINED: {
  36. const state = store.getState();
  37. const { room } = state['features/base/conference'];
  38. const { name, id } = getLocalParticipant(state);
  39. APP.API.notifyConferenceJoined(
  40. room,
  41. id,
  42. {
  43. displayName: name,
  44. formattedDisplayName: appendSuffix(
  45. name,
  46. interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME
  47. ),
  48. avatarURL: getAvatarURLByParticipantId(state, id)
  49. }
  50. );
  51. break;
  52. }
  53. case KICKED_OUT:
  54. APP.API.notifyKickedOut(
  55. {
  56. id: getLocalParticipant(store.getState()).id,
  57. local: true
  58. },
  59. { id: action.participant.getId() }
  60. );
  61. break;
  62. case NOTIFY_CAMERA_ERROR:
  63. if (action.error) {
  64. APP.API.notifyOnCameraError(
  65. action.error.name, action.error.message);
  66. }
  67. break;
  68. case NOTIFY_MIC_ERROR:
  69. if (action.error) {
  70. APP.API.notifyOnMicError(action.error.name, action.error.message);
  71. }
  72. break;
  73. case PARTICIPANT_KICKED:
  74. APP.API.notifyKickedOut(
  75. {
  76. id: action.kicked,
  77. local: false
  78. },
  79. { id: action.kicker });
  80. break;
  81. case SET_FILMSTRIP_VISIBLE:
  82. APP.API.notifyFilmstripDisplayChanged(action.visible);
  83. break;
  84. case SUBMIT_FEEDBACK:
  85. APP.API.notifyFeedbackSubmitted();
  86. break;
  87. }
  88. return result;
  89. });