Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(conference) move endpointMessageReceived action

Saúl Ibarra Corretgé0268374b88e5
diff --git a/conference.js b/conference.js
index 627fc0bf03..f715ce0275 100644
--- a/conference.js
+++ b/conference.js
@@ -38,6 +38,7 @@ import {
dataChannelClosed,
dataChannelOpened,
e2eRttChanged,
+ endpointMessageReceived,
kickedOut,
lockStateChanged,
nonParticipantMessageReceived,
@@ -162,7 +163,6 @@ import { isScreenAudioShared } from './react/features/screen-share/functions';
import { toggleScreenshotCaptureSummary } from './react/features/screenshot-capture/actions';
import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/AudioMixerEffect';
import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
-import { endpointMessageReceived } from './react/features/subtitles/actions.any';
import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
import { muteLocal } from './react/features/video-menu/actions.any';
import { iAmVisitor } from './react/features/visitors/functions';
@@ -1824,28 +1824,24 @@ export default {
room.on(
JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
- (...args) => {
- APP.store.dispatch(endpointMessageReceived(...args));
- if (args && args.length >= 2) {
- const [ sender, eventData ] = args;
-
- if (eventData.name === ENDPOINT_TEXT_MESSAGE_NAME) {
- APP.API.notifyEndpointTextMessageReceived({
- senderInfo: {
- jid: sender._jid,
- id: sender._id
- },
- eventData
- });
- }
+ (participant, data) => {
+ APP.store.dispatch(endpointMessageReceived(participant, data));
+ if (data?.name === ENDPOINT_TEXT_MESSAGE_NAME) {
+ APP.API.notifyEndpointTextMessageReceived({
+ senderInfo: {
+ jid: participant.getJid(),
+ id: participant.getId()
+ },
+ eventData: data
+ });
}
});
room.on(
JitsiConferenceEvents.NON_PARTICIPANT_MESSAGE_RECEIVED,
- (...args) => {
- APP.store.dispatch(nonParticipantMessageReceived(...args));
- APP.API.notifyNonParticipantMessageReceived(...args);
+ (id, data) => {
+ APP.store.dispatch(nonParticipantMessageReceived(id, data));
+ APP.API.notifyNonParticipantMessageReceived(id, data);
});
room.on(
diff --git a/react/features/base/conference/actionTypes.ts b/react/features/base/conference/actionTypes.ts
index 6ea2748393..adabbab60f 100644
--- a/react/features/base/conference/actionTypes.ts
+++ b/react/features/base/conference/actionTypes.ts
@@ -178,6 +178,18 @@ export const DATA_CHANNEL_OPENED = 'DATA_CHANNEL_OPENED';
*/
export const DATA_CHANNEL_CLOSED = 'DATA_CHANNEL_CLOSED';
+/**
+ * The type of (redux) action which indicates that an endpoint message
+ * sent by another participant to the data channel is received.
+ *
+ * {
+ * type: ENDPOINT_MESSAGE_RECEIVED,
+ * participant: Object,
+ * data: Object
+ * }
+ */
+export const ENDPOINT_MESSAGE_RECEIVED = 'ENDPOINT_MESSAGE_RECEIVED';
+
/**
* The type of action which signals that the user has been kicked out from
* the conference.
diff --git a/react/features/base/conference/actions.ts b/react/features/base/conference/actions.ts
index 2d98a9f351..78c026f351 100644
--- a/react/features/base/conference/actions.ts
+++ b/react/features/base/conference/actions.ts
@@ -1,7 +1,6 @@
import { createStartMutedConfigurationEvent } from '../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../analytics/functions';
import { IReduxState, IStore } from '../../app/types';
-import { endpointMessageReceived } from '../../subtitles/actions.any';
import { setIAmVisitor } from '../../visitors/actions';
import { iAmVisitor } from '../../visitors/functions';
import { overwriteConfig } from '../config/actions';
@@ -48,6 +47,7 @@ import {
DATA_CHANNEL_CLOSED,
DATA_CHANNEL_OPENED,
E2E_RTT_CHANGED,
+ ENDPOINT_MESSAGE_RECEIVED,
KICKED_OUT,
LOCK_STATE_CHANGED,
NON_PARTICIPANT_MESSAGE_RECEIVED,
@@ -630,6 +630,25 @@ export function dataChannelClosed(code: number, reason: string) {
};
}
+/**
+ * Signals that a participant sent an endpoint message on the data channel.
+ *
+ * @param {Object} participant - The participant details sending the message.
+ * @param {Object} data - The data carried by the endpoint message.
+ * @returns {{
+* type: ENDPOINT_MESSAGE_RECEIVED,
+* participant: Object,
+* data: Object
+* }}
+*/
+export function endpointMessageReceived(participant: Object, data: Object) {
+ return {
+ type: ENDPOINT_MESSAGE_RECEIVED,
+ participant,
+ data
+ };
+}
+
/**
* Action to end a conference for all participants.
*
diff --git a/react/features/subtitles/actionTypes.ts b/react/features/subtitles/actionTypes.ts
index 346c3ffff0..772fc1f780 100644
--- a/react/features/subtitles/actionTypes.ts
+++ b/react/features/subtitles/actionTypes.ts
@@ -1,16 +1,3 @@
-
-/**
- * The type of (redux) action which indicates that an endpoint message
- * sent by another participant to the data channel is received.
- *
- * {
- * type: ENDPOINT_MESSAGE_RECEIVED,
- * participant: Object,
- * json: Object
- * }
- */
-export const ENDPOINT_MESSAGE_RECEIVED = 'ENDPOINT_MESSAGE_RECEIVED';
-
/**
* The type of (redux) action which indicates that an existing transcript
* has to be removed from the state.
diff --git a/react/features/subtitles/actions.any.ts b/react/features/subtitles/actions.any.ts
index b7857a042b..358209565d 100644
--- a/react/features/subtitles/actions.any.ts
+++ b/react/features/subtitles/actions.any.ts
@@ -1,32 +1,12 @@
import { DEFAULT_LANGUAGE } from '../base/i18n/i18next';
import {
- ENDPOINT_MESSAGE_RECEIVED,
REMOVE_TRANSCRIPT_MESSAGE,
SET_REQUESTING_SUBTITLES,
TOGGLE_REQUESTING_SUBTITLES,
UPDATE_TRANSCRIPT_MESSAGE
} from './actionTypes';
-/**
- * Signals that a participant sent an endpoint message on the data channel.
- *
- * @param {Object} participant - The participant details sending the message.
- * @param {Object} json - The json carried by the endpoint message.
- * @returns {{
- * type: ENDPOINT_MESSAGE_RECEIVED,
- * participant: Object,
- * json: Object
- * }}
- */
-export function endpointMessageReceived(participant: Object, json: Object) {
- return {
- type: ENDPOINT_MESSAGE_RECEIVED,
- participant,
- json
- };
-}
-
/**
* Signals that a transcript has to be removed from the state.
*
diff --git a/react/features/subtitles/middleware.ts b/react/features/subtitles/middleware.ts
index 755a1a37e6..4661444b66 100644
--- a/react/features/subtitles/middleware.ts
+++ b/react/features/subtitles/middleware.ts
@@ -1,10 +1,10 @@
import { AnyAction } from 'redux';
import { IStore } from '../app/types';
+import { ENDPOINT_MESSAGE_RECEIVED } from '../base/conference/actionTypes';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import {
- ENDPOINT_MESSAGE_RECEIVED,
SET_REQUESTING_SUBTITLES,
TOGGLE_REQUESTING_SUBTITLES
} from './actionTypes';
@@ -90,7 +90,7 @@ MiddlewareRegistry.register(store => next => action => {
* @returns {Object} The value returned by {@code next(action)}.
*/
function _endpointMessageReceived({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
- const { json } = action;
+ const { data: json } = action;
if (![ JSON_TYPE_TRANSCRIPTION_RESULT, JSON_TYPE_TRANSLATION_RESULT ].includes(json?.type)) {
return next(action);