Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(external-api) Fix notify audio muted/audio available
Horatiu Muresan35442c60944f
diff --git a/conference.js b/conference.jsindex 80ebe4c93e..fc72a50609 100644--- a/conference.js+++ b/conference.js@@ -2983,7 +2983,6 @@ export default {const available = audioDeviceCount > 0 || Boolean(localAudio);APP.store.dispatch(setAudioAvailable(available));- APP.API.notifyAudioAvailabilityChanged(available);},/**@@ -3247,7 +3246,6 @@ export default {*/setAudioMuteStatus(muted) {APP.UI.setAudioMuted(this.getMyUserId(), muted);- APP.API.notifyAudioMutedStatusChanged(muted);},/**diff --git a/react/features/base/media/middleware.web.ts b/react/features/base/media/middleware.web.tsindex 674bd0a0bd..23cf5571ef 100644--- a/react/features/base/media/middleware.web.ts+++ b/react/features/base/media/middleware.web.ts@@ -14,6 +14,8 @@ import MiddlewareRegistry from '../redux/MiddlewareRegistry';import { SET_VIDEO_MUTED } from './actionTypes';+import './subscriber';+/*** Implements the entry point of the middleware of the feature base/media.*diff --git a/react/features/base/media/subscriber.ts b/react/features/base/media/subscriber.tsnew file mode 100644index 0000000000..8c7188ccd2--- /dev/null+++ b/react/features/base/media/subscriber.ts@@ -0,0 +1,21 @@+import { IState, IStore } from '../../app/types';+import StateListenerRegistry from '../redux/StateListenerRegistry';+++declare let APP: any;++/**+ * Notifies when the local audio mute state changes.+ */+StateListenerRegistry.register(+ /* selector */ (state: IState) => state['features/base/media'].audio.muted,+ /* listener */ (muted: boolean, store: IStore, previousMuted: boolean) => {+ if (typeof APP !== 'object') {+ return;+ }++ if (muted !== previousMuted) {+ APP.API.notifyAudioMutedStatusChanged(muted);+ }+ }+);diff --git a/react/features/base/redux/StateListenerRegistry.ts b/react/features/base/redux/StateListenerRegistry.tsindex 0418f4955b..d4d5fb632e 100644--- a/react/features/base/redux/StateListenerRegistry.ts+++ b/react/features/base/redux/StateListenerRegistry.ts@@ -26,7 +26,7 @@ type Listener* The type selector supported for registration with* {@link StateListenerRegistry} in association with a {@link Listener}.*- * @param {Object} state - The redux state from which the {@code Selector} is to+ * @param {IState} state - The redux state from which the {@code Selector} is to* derive data.* @param {any} prevSelection - The value previously derived from the redux* store/state by the {@code Selector}. Provided in case the {@code Selector}diff --git a/react/features/toolbox/functions.any.js b/react/features/toolbox/functions.any.tssimilarity index 66%rename from react/features/toolbox/functions.any.jsrename to react/features/toolbox/functions.any.tsindex dc83e5c166..36379a311a 100644--- a/react/features/toolbox/functions.any.js+++ b/react/features/toolbox/functions.any.ts@@ -1,12 +1,12 @@-// @flow+import { IState } from '../app/types';/*** Indicates if the audio mute button is disabled or not.*- * @param {Object} state - The state from the Redux store.+ * @param {IState} state - The state from the Redux store.* @returns {boolean}*/-export function isAudioMuteButtonDisabled(state: Object) {+export function isAudioMuteButtonDisabled(state: IState) {const { available, muted, unmuteBlocked } = state['features/base/media'].audio;const { startSilent } = state['features/base/config'];diff --git a/react/features/toolbox/middleware.js b/react/features/toolbox/middleware.jsindex d4289acc6a..beda68e6e4 100644--- a/react/features/toolbox/middleware.js+++ b/react/features/toolbox/middleware.js@@ -8,6 +8,7 @@ import {SET_FULL_SCREEN} from './actionTypes';+import './subscriber';declare var APP: Object;diff --git a/react/features/toolbox/subscriber.ts b/react/features/toolbox/subscriber.tsnew file mode 100644index 0000000000..87f2ccc19c--- /dev/null+++ b/react/features/toolbox/subscriber.ts@@ -0,0 +1,22 @@+import { IState, IStore } from '../app/types';+import StateListenerRegistry from '../base/redux/StateListenerRegistry';++import { isAudioMuteButtonDisabled } from './functions.any';++declare let APP: any;++/**+ * Notifies when audio availability changes.+ */+StateListenerRegistry.register(+ /* selector */ (state: IState) => isAudioMuteButtonDisabled(state),+ /* listener */ (disabled: boolean, store: IStore, previousDisabled: boolean) => {+ if (typeof APP !== 'object') {+ return;+ }++ if (disabled !== previousDisabled) {+ APP.API.notifyAudioAvailabilityChanged(!disabled);+ }+ }+);