浏览代码

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.
master
Jaya Allamsetty 3 年前
父节点
当前提交
b19e4d76b5

+ 2
- 14
conference.js 查看文件

@@ -76,8 +76,6 @@ import {
76 76
 import {
77 77
     getStartWithAudioMuted,
78 78
     getStartWithVideoMuted,
79
-    isAudioMuted,
80
-    isVideoMuted,
81 79
     isVideoMutedByUser,
82 80
     MEDIA_TYPE,
83 81
     setAudioAvailable,
@@ -2264,22 +2262,12 @@ export default {
2264 2262
         room.on(
2265 2263
             JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,
2266 2264
             disableAudioMuteChange => {
2267
-                const muted = isAudioMuted(APP.store.getState());
2268
-
2269
-                // Disable the mute button only if its muted.
2270
-                if (!disableAudioMuteChange || (disableAudioMuteChange && muted)) {
2271
-                    APP.store.dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
2272
-                }
2265
+                APP.store.dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
2273 2266
             });
2274 2267
         room.on(
2275 2268
             JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED,
2276 2269
             disableVideoMuteChange => {
2277
-                const muted = isVideoMuted(APP.store.getState());
2278
-
2279
-                // Disable the mute button only if its muted.
2280
-                if (!disableVideoMuteChange || (disableVideoMuteChange && muted)) {
2281
-                    APP.store.dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
2282
-                }
2270
+                APP.store.dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
2283 2271
             });
2284 2272
 
2285 2273
         APP.UI.addListener(UIEvents.AUDIO_MUTED, muted => {

+ 2
- 14
react/features/base/conference/actions.js 查看文件

@@ -12,8 +12,6 @@ import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection';
12 12
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
13 13
 import {
14 14
     MEDIA_TYPE,
15
-    isAudioMuted,
16
-    isVideoMuted,
17 15
     setAudioMuted,
18 16
     setAudioUnmutePermissions,
19 17
     setVideoMuted,
@@ -158,22 +156,12 @@ function _addConferenceListeners(conference, dispatch, state) {
158 156
     conference.on(
159 157
         JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,
160 158
         disableAudioMuteChange => {
161
-            const muted = isAudioMuted(state);
162
-
163
-            // Disable the mute button only if its muted.
164
-            if (!disableAudioMuteChange || (disableAudioMuteChange && muted)) {
165
-                dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
166
-            }
159
+            dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
167 160
         });
168 161
     conference.on(
169 162
         JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED,
170 163
         disableVideoMuteChange => {
171
-            const muted = isVideoMuted(state);
172
-
173
-            // Disable the mute button only if its muted.
174
-            if (!disableVideoMuteChange || (disableVideoMuteChange && muted)) {
175
-                dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
176
-            }
164
+            dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
177 165
         });
178 166
 
179 167
     // Dispatches into features/base/tracks follow:

+ 9
- 2
react/features/base/media/middleware.js 查看文件

@@ -20,6 +20,7 @@ import { MiddlewareRegistry } from '../redux';
20 20
 import { getPropertyValue } from '../settings';
21 21
 import {
22 22
     destroyLocalTracks,
23
+    isLocalTrackMuted,
23 24
     isLocalVideoTrackDesktop,
24 25
     setTrackMuted,
25 26
     TRACK_ADDED
@@ -85,8 +86,11 @@ MiddlewareRegistry.register(store => next => action => {
85 86
 
86 87
     case SET_AUDIO_UNMUTE_PERMISSIONS: {
87 88
         const { blocked } = action;
89
+        const state = store.getState();
90
+        const tracks = state['features/base/tracks'];
91
+        const isAudioMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
88 92
 
89
-        if (blocked) {
93
+        if (blocked && isAudioMuted) {
90 94
             store.dispatch(showWarningNotification({
91 95
                 descriptionKey: 'notify.audioUnmuteBlockedDescription',
92 96
                 titleKey: 'notify.audioUnmuteBlockedTitle'
@@ -107,8 +111,11 @@ MiddlewareRegistry.register(store => next => action => {
107 111
 
108 112
     case SET_VIDEO_UNMUTE_PERMISSIONS: {
109 113
         const { blocked } = action;
114
+        const state = store.getState();
115
+        const tracks = state['features/base/tracks'];
116
+        const isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
110 117
 
111
-        if (blocked) {
118
+        if (blocked && isVideoMuted) {
112 119
             store.dispatch(showWarningNotification({
113 120
                 descriptionKey: 'notify.videoUnmuteBlockedDescription',
114 121
                 titleKey: 'notify.videoUnmuteBlockedTitle'

+ 4
- 4
react/features/base/media/reducer.js 查看文件

@@ -35,7 +35,7 @@ import { CAMERA_FACING_MODE } from './constants';
35 35
  */
36 36
 export const _AUDIO_INITIAL_MEDIA_STATE = {
37 37
     available: true,
38
-    blocked: false,
38
+    unmuteBlocked: false,
39 39
     muted: false
40 40
 };
41 41
 
@@ -65,7 +65,7 @@ function _audio(state = _AUDIO_INITIAL_MEDIA_STATE, action) {
65 65
     case SET_AUDIO_UNMUTE_PERMISSIONS:
66 66
         return {
67 67
             ...state,
68
-            blocked: action.blocked
68
+            unmuteBlocked: action.blocked
69 69
         };
70 70
 
71 71
     default:
@@ -92,7 +92,7 @@ function _audio(state = _AUDIO_INITIAL_MEDIA_STATE, action) {
92 92
  */
93 93
 export const _VIDEO_INITIAL_MEDIA_STATE = {
94 94
     available: true,
95
-    blocked: false,
95
+    unmuteBlocked: false,
96 96
     facingMode: CAMERA_FACING_MODE.USER,
97 97
     muted: 0,
98 98
 
@@ -139,7 +139,7 @@ function _video(state = _VIDEO_INITIAL_MEDIA_STATE, action) {
139 139
     case SET_VIDEO_UNMUTE_PERMISSIONS:
140 140
         return {
141 141
             ...state,
142
-            blocked: action.blocked
142
+            unmuteBlocked: action.blocked
143 143
         };
144 144
 
145 145
     case STORE_VIDEO_TRANSFORM:

+ 2
- 2
react/features/toolbox/functions.any.js 查看文件

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

+ 4
- 2
react/features/toolbox/functions.native.js 查看文件

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

+ 2
- 2
react/features/toolbox/functions.web.js 查看文件

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

正在加载...
取消
保存