2022-08-03 14:58:51 +02:00
|
|
|
import { getAppProp } from '../../base/app/functions';
|
|
|
|
|
import {
|
2023-08-02 04:24:52 -05:00
|
|
|
CONFERENCE_BLURRED,
|
|
|
|
|
CONFERENCE_FOCUSED,
|
2022-08-03 14:58:51 +02:00
|
|
|
CONFERENCE_JOINED,
|
|
|
|
|
CONFERENCE_LEFT,
|
2023-11-17 11:09:31 +01:00
|
|
|
CONFERENCE_WILL_JOIN
|
2022-08-03 14:58:51 +02:00
|
|
|
} from '../../base/conference/actionTypes';
|
2023-11-17 11:09:31 +01:00
|
|
|
import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes';
|
2023-12-12 08:48:06 +01:00
|
|
|
import { PARTICIPANT_JOINED, PARTICIPANT_LEFT } from '../../base/participants/actionTypes';
|
2022-08-03 14:58:51 +02:00
|
|
|
import MiddlewareRegistry from '../../base/redux/MiddlewareRegistry';
|
|
|
|
|
import { READY_TO_CLOSE } from '../external-api/actionTypes';
|
|
|
|
|
import { participantToParticipantInfo } from '../external-api/functions';
|
2023-07-28 19:31:06 -05:00
|
|
|
import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture/actionTypes';
|
2022-08-03 14:58:51 +02:00
|
|
|
|
|
|
|
|
import { isExternalAPIAvailable } from './functions';
|
|
|
|
|
|
|
|
|
|
const externalAPIEnabled = isExternalAPIAvailable();
|
2023-11-07 12:22:02 +02:00
|
|
|
|
2022-08-03 14:58:51 +02:00
|
|
|
|
|
|
|
|
/**
|
2023-11-07 12:22:02 +02:00
|
|
|
* Check if native modules are being used or not.
|
|
|
|
|
* If not, then the init of middleware doesn't happen.
|
2022-08-03 14:58:51 +02:00
|
|
|
*/
|
|
|
|
|
!externalAPIEnabled && MiddlewareRegistry.register(store => next => action => {
|
|
|
|
|
const result = next(action);
|
|
|
|
|
const { type } = action;
|
|
|
|
|
const rnSdkHandlers = getAppProp(store, 'rnSdkHandlers');
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
2023-11-17 11:09:31 +01:00
|
|
|
case SET_AUDIO_MUTED:
|
2023-11-16 09:28:52 +01:00
|
|
|
rnSdkHandlers?.onAudioMutedChanged && rnSdkHandlers?.onAudioMutedChanged(action.muted);
|
|
|
|
|
break;
|
2023-11-17 11:09:31 +01:00
|
|
|
case SET_VIDEO_MUTED:
|
|
|
|
|
rnSdkHandlers?.onVideoMutedChanged && rnSdkHandlers?.onVideoMutedChanged(Boolean(action.muted));
|
2023-11-16 09:28:52 +01:00
|
|
|
break;
|
2023-08-02 04:24:52 -05:00
|
|
|
case CONFERENCE_BLURRED:
|
|
|
|
|
rnSdkHandlers?.onConferenceBlurred && rnSdkHandlers?.onConferenceBlurred();
|
|
|
|
|
break;
|
|
|
|
|
case CONFERENCE_FOCUSED:
|
|
|
|
|
rnSdkHandlers?.onConferenceFocused && rnSdkHandlers?.onConferenceFocused();
|
|
|
|
|
break;
|
2022-08-03 14:58:51 +02:00
|
|
|
case CONFERENCE_JOINED:
|
2023-07-12 17:28:30 +03:00
|
|
|
rnSdkHandlers?.onConferenceJoined && rnSdkHandlers?.onConferenceJoined();
|
2022-08-03 14:58:51 +02:00
|
|
|
break;
|
2023-08-01 10:40:13 +03:00
|
|
|
case CONFERENCE_LEFT:
|
|
|
|
|
// Props are torn down at this point, perhaps need to leave this one out
|
|
|
|
|
break;
|
2022-08-03 14:58:51 +02:00
|
|
|
case CONFERENCE_WILL_JOIN:
|
2023-07-12 17:28:30 +03:00
|
|
|
rnSdkHandlers?.onConferenceWillJoin && rnSdkHandlers?.onConferenceWillJoin();
|
2022-08-03 14:58:51 +02:00
|
|
|
break;
|
2023-08-01 10:40:13 +03:00
|
|
|
case ENTER_PICTURE_IN_PICTURE:
|
|
|
|
|
rnSdkHandlers?.onEnterPictureInPicture && rnSdkHandlers?.onEnterPictureInPicture();
|
2022-08-03 14:58:51 +02:00
|
|
|
break;
|
|
|
|
|
case PARTICIPANT_JOINED: {
|
|
|
|
|
const { participant } = action;
|
|
|
|
|
const participantInfo = participantToParticipantInfo(participant);
|
|
|
|
|
|
2023-07-12 17:28:30 +03:00
|
|
|
rnSdkHandlers?.onParticipantJoined && rnSdkHandlers?.onParticipantJoined(participantInfo);
|
2022-08-03 14:58:51 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2023-12-12 08:48:06 +01:00
|
|
|
case PARTICIPANT_LEFT: {
|
|
|
|
|
const { participant } = action;
|
|
|
|
|
|
|
|
|
|
const { id } = participant ?? {};
|
|
|
|
|
|
|
|
|
|
rnSdkHandlers?.onParticipantLeft && rnSdkHandlers?.onParticipantLeft({ id });
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-08-01 10:40:13 +03:00
|
|
|
case READY_TO_CLOSE:
|
|
|
|
|
rnSdkHandlers?.onReadyToClose && rnSdkHandlers?.onReadyToClose();
|
2023-07-28 19:31:06 -05:00
|
|
|
break;
|
2022-08-03 14:58:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2023-11-07 12:22:02 +02:00
|
|
|
});
|