123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- // @flow
-
- import {
- CONFERENCE_FAILED,
- CONFERENCE_JOINED,
- KICKED_OUT
- } from '../base/conference';
- import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
- import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
- import {
- PARTICIPANT_KICKED,
- getAvatarURLByParticipantId,
- getLocalParticipant
- } from '../base/participants';
- import { MiddlewareRegistry } from '../base/redux';
- import { appendSuffix } from '../display-name';
- import { SUBMIT_FEEDBACK } from '../feedback';
- import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
-
- declare var APP: Object;
- declare var interfaceConfig: Object;
-
- /**
- * The middleware of the feature {@code external-api}.
- *
- * @returns {Function}
- */
- MiddlewareRegistry.register(store => next => action => {
- const result = next(action);
-
- switch (action.type) {
- case CONFERENCE_FAILED: {
- if (action.conference
- && action.error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) {
- APP.API.notifyOnPasswordRequired();
- }
- break;
- }
-
- case CONFERENCE_JOINED: {
- const state = store.getState();
- const { room } = state['features/base/conference'];
- const { name, id } = getLocalParticipant(state);
-
- APP.API.notifyConferenceJoined(
- room,
- id,
- {
- displayName: name,
- formattedDisplayName: appendSuffix(
- name,
- interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME
- ),
- avatarURL: getAvatarURLByParticipantId(state, id)
- }
- );
-
- break;
- }
-
- case KICKED_OUT:
- APP.API.notifyKickedOut(
- {
- id: getLocalParticipant(store.getState()).id,
- local: true
- },
- { id: action.participant.getId() }
- );
- break;
-
- case NOTIFY_CAMERA_ERROR:
- if (action.error) {
- APP.API.notifyOnCameraError(
- action.error.name, action.error.message);
- }
- break;
-
- case NOTIFY_MIC_ERROR:
- if (action.error) {
- APP.API.notifyOnMicError(action.error.name, action.error.message);
- }
- break;
-
- case PARTICIPANT_KICKED:
- APP.API.notifyKickedOut(
- {
- id: action.kicked,
- local: false
- },
- { id: action.kicker });
- break;
-
- case SET_FILMSTRIP_VISIBLE:
- APP.API.notifyFilmstripDisplayChanged(action.visible);
- break;
-
- case SUBMIT_FEEDBACK:
- APP.API.notifyFeedbackSubmitted();
- break;
- }
-
- return result;
- });
|