Skip to content

Commit

Permalink
fix(external-api) Fix notify audio muted/audio available
Browse files Browse the repository at this point in the history
  • Loading branch information
horymury committed Sep 14, 2022
1 parent d6f3c2a commit 35442c6
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 6 deletions.
2 changes: 0 additions & 2 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,6 @@ export default {
const available = audioDeviceCount > 0 || Boolean(localAudio);

APP.store.dispatch(setAudioAvailable(available));
APP.API.notifyAudioAvailabilityChanged(available);
},

/**
Expand Down Expand Up @@ -3247,7 +3246,6 @@ export default {
*/
setAudioMuteStatus(muted) {
APP.UI.setAudioMuted(this.getMyUserId(), muted);
APP.API.notifyAudioMutedStatusChanged(muted);
},

/**
Expand Down
2 changes: 2 additions & 0 deletions react/features/base/media/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
21 changes: 21 additions & 0 deletions react/features/base/media/subscriber.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
);
2 changes: 1 addition & 1 deletion react/features/base/redux/StateListenerRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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'];

Expand Down
1 change: 1 addition & 0 deletions react/features/toolbox/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SET_FULL_SCREEN
} from './actionTypes';

import './subscriber';

declare var APP: Object;

Expand Down
22 changes: 22 additions & 0 deletions react/features/toolbox/subscriber.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
);

0 comments on commit 35442c6

Please sign in to comment.