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: Fixes updating local UI startMuted state.

damencho3047b4c8c48d
diff --git a/conference.js b/conference.js
index d1ad3057d8..e8477c7433 100644
--- a/conference.js
+++ b/conference.js
@@ -50,7 +50,8 @@ import {
commonUserJoinedHandling,
commonUserLeftHandling,
getConferenceOptions,
- sendLocalParticipant
+ sendLocalParticipant,
+ updateTrackMuteState
} from './react/features/base/conference/functions';
import { getReplaceParticipant, getSsrcRewritingFeatureFlag } from './react/features/base/config/functions';
import { connect } from './react/features/base/connection/actions.web';
@@ -1663,8 +1664,12 @@ export default {
room.on(
JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
({ audio, video }) => {
- APP.store.dispatch(
- onStartMutedPolicyChanged(audio, video));
+ APP.store.dispatch(onStartMutedPolicyChanged(audio, video));
+
+ const state = APP.store.getState();
+
+ updateTrackMuteState(state, APP.store.dispatch, true);
+ updateTrackMuteState(state, APP.store.dispatch, false);
}
);
diff --git a/react/features/base/conference/actions.any.ts b/react/features/base/conference/actions.any.ts
index 4f3292f64c..ddec6cf624 100644
--- a/react/features/base/conference/actions.any.ts
+++ b/react/features/base/conference/actions.any.ts
@@ -83,7 +83,8 @@ import {
getConferenceState,
getCurrentConference,
getVisitorOptions,
- sendLocalParticipant
+ sendLocalParticipant,
+ updateTrackMuteState
} from './functions';
import logger from './logger';
import { IConferenceMetadata, IJitsiConference } from './reducer';
@@ -186,6 +187,15 @@ function _addConferenceListeners(conference: IJitsiConference, dispatch: IStore[
(disableVideoMuteChange: boolean) => {
dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
});
+ conference.on(
+ JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
+ ({ audio, video }: { audio: boolean; video: boolean; }) => {
+ dispatch(onStartMutedPolicyChanged(audio, video));
+
+ updateTrackMuteState(state, dispatch, true);
+ updateTrackMuteState(state, dispatch, false);
+ }
+ );
// Dispatches into features/base/tracks follow:
@@ -1013,6 +1023,8 @@ export function setStartMutedPolicy(
audio: startAudioMuted,
video: startVideoMuted
});
+
+ dispatch(onStartMutedPolicyChanged(startAudioMuted, startVideoMuted));
};
}
diff --git a/react/features/base/conference/constants.ts b/react/features/base/conference/constants.ts
index bc84f8a148..2b7c85f9df 100644
--- a/react/features/base/conference/constants.ts
+++ b/react/features/base/conference/constants.ts
@@ -40,3 +40,8 @@ export const CONFERENCE_LEAVE_REASONS = {
SWITCH_ROOM: 'switch_room',
UNRECOVERABLE_ERROR: 'unrecoverable_error'
};
+
+/**
+ * The ID of the notification that is shown when the user is muted by focus.
+ */
+export const START_MUTED_NOTIFICATION_ID = 'start-muted';
diff --git a/react/features/base/conference/functions.ts b/react/features/base/conference/functions.ts
index 4fe7c7fb07..5db9f934c0 100644
--- a/react/features/base/conference/functions.ts
+++ b/react/features/base/conference/functions.ts
@@ -3,9 +3,13 @@ import { upperFirst, words } from 'lodash-es';
import { getName } from '../../app/functions';
import { IReduxState, IStore } from '../../app/types';
+import { showNotification } from '../../notifications/actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
import { determineTranscriptionLanguage } from '../../transcribing/functions';
import { IStateful } from '../app/types';
import { JitsiTrackErrors } from '../lib-jitsi-meet';
+import { setAudioMuted, setVideoMuted } from '../media/actions';
+import { VIDEO_MUTISM_AUTHORITY } from '../media/constants';
import {
participantJoined,
participantLeft
@@ -22,7 +26,8 @@ import { setObfuscatedRoom } from './actions';
import {
AVATAR_URL_COMMAND,
EMAIL_COMMAND,
- JITSI_CONFERENCE_URL_KEY
+ JITSI_CONFERENCE_URL_KEY,
+ START_MUTED_NOTIFICATION_ID
} from './constants';
import logger from './logger';
import { IJitsiConference } from './reducer';
@@ -574,3 +579,42 @@ function safeStartCase(s = '') {
(result, word, index) => result + (index ? ' ' : '') + upperFirst(word)
, '');
}
+
+/**
+ * Updates the mute state of the track based on the start muted policy.
+ *
+ * @param {Object|Function} stateful - Either the whole Redux state object or the Redux store's {@code getState} method.
+ * @param {Function} dispatch - Redux dispatch function.
+ * @param {boolean} isAudio - Whether the track is audio or video.
+ * @returns {void}
+ */
+export function updateTrackMuteState(stateful: IStateful, dispatch: IStore['dispatch'], isAudio: boolean) {
+ const state = toState(stateful);
+ const mutedPolicyKey = isAudio ? 'startAudioMutedPolicy' : 'startVideoMutedPolicy';
+ const mutedPolicyValue = state['features/base/conference'][mutedPolicyKey];
+
+ // Currently, the policy only supports force muting others, not unmuting them.
+ if (!mutedPolicyValue) {
+ return;
+ }
+
+ let muteStateUpdated = false;
+ const { muted } = isAudio ? state['features/base/media'].audio : state['features/base/media'].video;
+
+ if (isAudio && !Boolean(muted)) {
+ dispatch(setAudioMuted(mutedPolicyValue, true));
+ muteStateUpdated = true;
+ } else if (!isAudio && !Boolean(muted)) {
+ // TODO: Add a new authority for video mutism for the moderator case.
+ dispatch(setVideoMuted(mutedPolicyValue, VIDEO_MUTISM_AUTHORITY.USER, true));
+ muteStateUpdated = true;
+ }
+
+ if (muteStateUpdated) {
+ dispatch(showNotification({
+ titleKey: 'notify.mutedTitle',
+ descriptionKey: 'notify.muted',
+ uid: START_MUTED_NOTIFICATION_ID // use the same id, to make sure we show one notification
+ }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
+ }
+}
diff --git a/react/features/base/conference/middleware.any.ts b/react/features/base/conference/middleware.any.ts
index aefacfdeae..ca58e329ea 100644
--- a/react/features/base/conference/middleware.any.ts
+++ b/react/features/base/conference/middleware.any.ts
@@ -72,7 +72,6 @@ import {
} from './functions';
import logger from './logger';
import { IConferenceMetadata } from './reducer';
-import './subscriber';
/**
* Handler for before unload event.
diff --git a/react/features/base/conference/subscriber.ts b/react/features/base/conference/subscriber.ts
deleted file mode 100644
index 19ff88653f..0000000000
--- a/react/features/base/conference/subscriber.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { IStore } from '../../app/types';
-import { showNotification } from '../../notifications/actions';
-import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
-import { setAudioMuted, setVideoMuted } from '../media/actions';
-import { VIDEO_MUTISM_AUTHORITY } from '../media/constants';
-import StateListenerRegistry from '../redux/StateListenerRegistry';
-
-let hasShownNotification = false;
-
-/**
- * Handles changes in the start muted policy for audio and video tracks in the meta data set for the conference.
- */
-StateListenerRegistry.register(
- /* selector */ state => state['features/base/conference'].startAudioMutedPolicy,
- /* listener */ (startAudioMutedPolicy, store) => {
- _updateTrackMuteState(store, true);
- });
-
-StateListenerRegistry.register(
- /* selector */ state => state['features/base/conference'].startVideoMutedPolicy,
- /* listener */(startVideoMutedPolicy, store) => {
- _updateTrackMuteState(store, false);
- });
-
-/**
- * Updates the mute state of the track based on the start muted policy.
- *
- * @param {IStore} store - The redux store.
- * @param {boolean} isAudio - Whether the track is audio or video.
- * @returns {void}
- */
-function _updateTrackMuteState(store: IStore, isAudio: boolean) {
- const { dispatch, getState } = store;
- const mutedPolicyKey = isAudio ? 'startAudioMutedPolicy' : 'startVideoMutedPolicy';
- const mutedPolicyValue = getState()['features/base/conference'][mutedPolicyKey];
-
- // Currently, the policy only supports force muting others, not unmuting them.
- if (!mutedPolicyValue) {
- return;
- }
-
- let muteStateUpdated = false;
- const { muted } = isAudio ? getState()['features/base/media'].audio : getState()['features/base/media'].video;
-
- if (isAudio && !Boolean(muted)) {
- dispatch(setAudioMuted(mutedPolicyValue, true));
- muteStateUpdated = true;
- } else if (!isAudio && !Boolean(muted)) {
- // TODO: Add a new authority for video mutism for the moderator case.
- dispatch(setVideoMuted(mutedPolicyValue, VIDEO_MUTISM_AUTHORITY.USER, true));
- muteStateUpdated = true;
- }
-
- if (!hasShownNotification && muteStateUpdated) {
- hasShownNotification = true;
- dispatch(showNotification({
- titleKey: 'notify.mutedTitle',
- descriptionKey: 'notify.muted'
- }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
- }
-}