fix(media) dispatch the unmute blocked action irrepective of the muted state.

This fixes an issue where the user muted by focus is able to unmute themselves even when the sender limit has been reached.
This commit is contained in:
Jaya Allamsetty 2021-12-07 16:48:12 -05:00 committed by Дамян Минков
parent 65589937ea
commit b19e4d76b5
7 changed files with 25 additions and 40 deletions

View File

@ -76,8 +76,6 @@ import {
import { import {
getStartWithAudioMuted, getStartWithAudioMuted,
getStartWithVideoMuted, getStartWithVideoMuted,
isAudioMuted,
isVideoMuted,
isVideoMutedByUser, isVideoMutedByUser,
MEDIA_TYPE, MEDIA_TYPE,
setAudioAvailable, setAudioAvailable,
@ -2264,22 +2262,12 @@ export default {
room.on( room.on(
JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED, JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,
disableAudioMuteChange => { disableAudioMuteChange => {
const muted = isAudioMuted(APP.store.getState()); APP.store.dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
// Disable the mute button only if its muted.
if (!disableAudioMuteChange || (disableAudioMuteChange && muted)) {
APP.store.dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
}
}); });
room.on( room.on(
JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED, JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED,
disableVideoMuteChange => { disableVideoMuteChange => {
const muted = isVideoMuted(APP.store.getState()); APP.store.dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
// Disable the mute button only if its muted.
if (!disableVideoMuteChange || (disableVideoMuteChange && muted)) {
APP.store.dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
}
}); });
APP.UI.addListener(UIEvents.AUDIO_MUTED, muted => { APP.UI.addListener(UIEvents.AUDIO_MUTED, muted => {

View File

@ -12,8 +12,6 @@ import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection';
import { JitsiConferenceEvents } from '../lib-jitsi-meet'; import { JitsiConferenceEvents } from '../lib-jitsi-meet';
import { import {
MEDIA_TYPE, MEDIA_TYPE,
isAudioMuted,
isVideoMuted,
setAudioMuted, setAudioMuted,
setAudioUnmutePermissions, setAudioUnmutePermissions,
setVideoMuted, setVideoMuted,
@ -158,22 +156,12 @@ function _addConferenceListeners(conference, dispatch, state) {
conference.on( conference.on(
JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED, JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,
disableAudioMuteChange => { disableAudioMuteChange => {
const muted = isAudioMuted(state); dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
// Disable the mute button only if its muted.
if (!disableAudioMuteChange || (disableAudioMuteChange && muted)) {
dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
}
}); });
conference.on( conference.on(
JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED, JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED,
disableVideoMuteChange => { disableVideoMuteChange => {
const muted = isVideoMuted(state); dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
// Disable the mute button only if its muted.
if (!disableVideoMuteChange || (disableVideoMuteChange && muted)) {
dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
}
}); });
// Dispatches into features/base/tracks follow: // Dispatches into features/base/tracks follow:

View File

@ -20,6 +20,7 @@ import { MiddlewareRegistry } from '../redux';
import { getPropertyValue } from '../settings'; import { getPropertyValue } from '../settings';
import { import {
destroyLocalTracks, destroyLocalTracks,
isLocalTrackMuted,
isLocalVideoTrackDesktop, isLocalVideoTrackDesktop,
setTrackMuted, setTrackMuted,
TRACK_ADDED TRACK_ADDED
@ -85,8 +86,11 @@ MiddlewareRegistry.register(store => next => action => {
case SET_AUDIO_UNMUTE_PERMISSIONS: { case SET_AUDIO_UNMUTE_PERMISSIONS: {
const { blocked } = action; const { blocked } = action;
const state = store.getState();
const tracks = state['features/base/tracks'];
const isAudioMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
if (blocked) { if (blocked && isAudioMuted) {
store.dispatch(showWarningNotification({ store.dispatch(showWarningNotification({
descriptionKey: 'notify.audioUnmuteBlockedDescription', descriptionKey: 'notify.audioUnmuteBlockedDescription',
titleKey: 'notify.audioUnmuteBlockedTitle' titleKey: 'notify.audioUnmuteBlockedTitle'
@ -107,8 +111,11 @@ MiddlewareRegistry.register(store => next => action => {
case SET_VIDEO_UNMUTE_PERMISSIONS: { case SET_VIDEO_UNMUTE_PERMISSIONS: {
const { blocked } = action; const { blocked } = action;
const state = store.getState();
const tracks = state['features/base/tracks'];
const isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
if (blocked) { if (blocked && isVideoMuted) {
store.dispatch(showWarningNotification({ store.dispatch(showWarningNotification({
descriptionKey: 'notify.videoUnmuteBlockedDescription', descriptionKey: 'notify.videoUnmuteBlockedDescription',
titleKey: 'notify.videoUnmuteBlockedTitle' titleKey: 'notify.videoUnmuteBlockedTitle'

View File

@ -35,7 +35,7 @@ import { CAMERA_FACING_MODE } from './constants';
*/ */
export const _AUDIO_INITIAL_MEDIA_STATE = { export const _AUDIO_INITIAL_MEDIA_STATE = {
available: true, available: true,
blocked: false, unmuteBlocked: false,
muted: false muted: false
}; };
@ -65,7 +65,7 @@ function _audio(state = _AUDIO_INITIAL_MEDIA_STATE, action) {
case SET_AUDIO_UNMUTE_PERMISSIONS: case SET_AUDIO_UNMUTE_PERMISSIONS:
return { return {
...state, ...state,
blocked: action.blocked unmuteBlocked: action.blocked
}; };
default: default:
@ -92,7 +92,7 @@ function _audio(state = _AUDIO_INITIAL_MEDIA_STATE, action) {
*/ */
export const _VIDEO_INITIAL_MEDIA_STATE = { export const _VIDEO_INITIAL_MEDIA_STATE = {
available: true, available: true,
blocked: false, unmuteBlocked: false,
facingMode: CAMERA_FACING_MODE.USER, facingMode: CAMERA_FACING_MODE.USER,
muted: 0, muted: 0,
@ -139,7 +139,7 @@ function _video(state = _VIDEO_INITIAL_MEDIA_STATE, action) {
case SET_VIDEO_UNMUTE_PERMISSIONS: case SET_VIDEO_UNMUTE_PERMISSIONS:
return { return {
...state, ...state,
blocked: action.blocked unmuteBlocked: action.blocked
}; };
case STORE_VIDEO_TRANSFORM: case STORE_VIDEO_TRANSFORM:

View File

@ -7,7 +7,7 @@
* @returns {boolean} * @returns {boolean}
*/ */
export function isAudioMuteButtonDisabled(state: Object) { export function isAudioMuteButtonDisabled(state: Object) {
const { audio } = state['features/base/media']; const { available, muted, unmuteBlocked } = state['features/base/media'].audio;
return !(audio?.available && !audio?.blocked); return !available || (muted && unmuteBlocked);
} }

View File

@ -80,7 +80,9 @@ export function isToolboxVisible(stateful: Object | Function) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isVideoMuteButtonDisabled(state: Object) { export function isVideoMuteButtonDisabled(state: Object) {
const { video } = state['features/base/media']; const { muted, unmuteBlocked } = state['features/base/media'].video;
return !hasAvailableDevices(state, 'videoInput') || video?.blocked || isLocalVideoTrackDesktop(state); return !hasAvailableDevices(state, 'videoInput')
|| (unmuteBlocked && Boolean(muted))
|| isLocalVideoTrackDesktop(state);
} }

View File

@ -83,9 +83,9 @@ export function isVideoSettingsButtonDisabled(state: Object) {
* @returns {boolean} * @returns {boolean}
*/ */
export function isVideoMuteButtonDisabled(state: Object) { export function isVideoMuteButtonDisabled(state: Object) {
const { video } = state['features/base/media']; const { muted, unmuteBlocked } = state['features/base/media'].video;
return !hasAvailableDevices(state, 'videoInput') || video?.blocked; return !hasAvailableDevices(state, 'videoInput') || (unmuteBlocked && Boolean(muted));
} }
/** /**