Sfoglia il codice sorgente

Fix TypeError: Cannot read property 'isGuest' of undefined

j8
Lyubo Marinov 8 anni fa
parent
commit
3c31a60b32

+ 7
- 0
react/features/base/config/reducer.js Vedi File

@@ -58,6 +58,13 @@ function _setConfig(state, action) {
58 58
         // The config of INITIAL_STATE is meant to override the config
59 59
         // downloaded from the Jitsi Meet deployment because the former contains
60 60
         // values that are mandatory.
61
+        //
62
+        // FIXME At the time of this writing the hard-coded overriding values
63
+        // are specific to mobile/React Native but the source code here is
64
+        // executed on Web/React as well. The latter is not a practical problem
65
+        // right now because the rest of the Web/React source code does not read
66
+        // the overridden properties/values, it still relies on the global
67
+        // variable config.
61 68
         ...INITIAL_STATE
62 69
     };
63 70
 }

+ 1
- 7
react/features/base/lib-jitsi-meet/actions.js Vedi File

@@ -21,15 +21,9 @@ export function disposeLib() {
21 21
     return (dispatch: Dispatch<*>) => {
22 22
         dispatch({ type: LIB_WILL_DISPOSE });
23 23
 
24
-        // XXX We're wrapping it with Promise because:
25
-        // a) to be better aligned with initLib() method which is async;
26
-        // b) as currently there is no implementation for it in lib-jitsi-meet
27
-        //    and there is a big chance it will be async.
28 24
         // TODO Currently, lib-jitsi-meet doesn't have the functionality to
29 25
         // dispose itself.
30
-        return (
31
-            Promise.resolve()
32
-                .then(() => dispatch({ type: LIB_DID_DISPOSE })));
26
+        dispatch({ type: LIB_DID_DISPOSE });
33 27
     };
34 28
 }
35 29
 

+ 19
- 18
react/features/base/lib-jitsi-meet/middleware.js Vedi File

@@ -99,22 +99,23 @@ function _setConfig({ dispatch, getState }, next, action) {
99 99
     // disposed of first.
100 100
     // TODO Currently, disposeLib actually does not dispose of lib-jitsi-meet
101 101
     // because lib-jitsi-meet does not implement such functionality.
102
-    const disposeLibPromise
103
-        = initialized ? dispatch(disposeLib()) : Promise.resolve();
104
-
105
-    disposeLibPromise.then(() => {
106
-        // Let the new config into the Redux store (because initLib will read it
107
-        // from there).
108
-        next(action);
109
-
110
-        // FIXME Obviously, the following is bad design. However, I'm currently
111
-        // introducing the features base/config and base/logging and I'm trying
112
-        // to minimize the scope of the changes while I'm attempting to preserve
113
-        // compatibility with the existing partially React-ified Web source code
114
-        // and what was already executing on React Native. Additionally, I do
115
-        // not care to load logging_config.js on React Native.
116
-        dispatch(setLoggingConfig(window.loggingConfig));
117
-
118
-        dispatch(initLib());
119
-    });
102
+    if (initialized) {
103
+        dispatch(disposeLib());
104
+    }
105
+
106
+    // Let the new config into the Redux store (because initLib will read it
107
+    // from there).
108
+    const result = next(action);
109
+
110
+    // FIXME Obviously, the following is bad design. However, I'm currently
111
+    // introducing the features base/config and base/logging and I'm trying to
112
+    // minimize the scope of the changes while I'm attempting to preserve
113
+    // compatibility with the existing partially React-ified Web source code and
114
+    // what was already executing on React Native. Additionally, I do not care
115
+    // to load logging_config.js on React Native.
116
+    dispatch(setLoggingConfig(window.loggingConfig));
117
+
118
+    dispatch(initLib());
119
+
120
+    return result;
120 121
 }

+ 1
- 1
react/features/base/react/Platform.web.js Vedi File

@@ -1,6 +1,6 @@
1 1
 /* @flow */
2 2
 
3
-const userAgent = navigator.userAgent;
3
+const { userAgent } = navigator;
4 4
 let OS;
5 5
 
6 6
 if (userAgent.match(/Android/i)) {

+ 9
- 18
react/features/toolbox/actions.web.js Vedi File

@@ -172,9 +172,8 @@ export function showDesktopSharingButton(): Function {
172 172
 export function showDialPadButton(show: boolean): Function {
173 173
     return (dispatch: Dispatch<*>) => {
174 174
         const buttonName = 'dialpad';
175
-        const shouldShow = UIUtil.isButtonEnabled(buttonName) && show;
176 175
 
177
-        if (shouldShow) {
176
+        if (show && UIUtil.isButtonEnabled(buttonName)) {
178 177
             dispatch(setToolbarButton(buttonName, {
179 178
                 hidden: false
180 179
             }));
@@ -205,11 +204,9 @@ export function showRecordingButton(): Function {
205 204
 export function showSharedVideoButton(): Function {
206 205
     return (dispatch: Dispatch<*>) => {
207 206
         const buttonName = 'sharedvideo';
208
-        const shouldShow
209
-            = UIUtil.isButtonEnabled(buttonName)
210
-                && !config.disableThirdPartyRequests;
211 207
 
212
-        if (shouldShow) {
208
+        if (UIUtil.isButtonEnabled(buttonName)
209
+                && !config.disableThirdPartyRequests) {
213 210
             dispatch(setToolbarButton(buttonName, {
214 211
                 hidden: false
215 212
             }));
@@ -218,28 +215,22 @@ export function showSharedVideoButton(): Function {
218 215
 }
219 216
 
220 217
 /**
221
- * Shows SIP call button if it's required and appropriate
222
- * flag is passed.
218
+ * Shows SIP call button if it's required and appropriate flag is passed.
223 219
  *
224 220
  * @param {boolean} show - Flag showing whether to show button or not.
225 221
  * @returns {Function}
226 222
  */
227 223
 export function showSIPCallButton(show: boolean): Function {
228
-    return (dispatch: Dispatch<*>) => {
224
+    return (dispatch: Dispatch<*>, getState: Function) => {
229 225
         const buttonName = 'sip';
230 226
 
231
-        // hide the button if there is a config to check for user roles,
232
-        // based on the token and the the user is guest
233
-        const shouldShow
234
-            = APP.conference.sipGatewayEnabled()
227
+        if (show
228
+                && APP.conference.sipGatewayEnabled()
235 229
                 && UIUtil.isButtonEnabled(buttonName)
236
-                && show
237 230
                 && (!config.enableUserRolesBasedOnToken
238
-                        || !APP.tokenData.isGuest);
239
-
240
-        if (shouldShow) {
231
+                    || !getState()['features/jwt'].isGuest)) {
241 232
             dispatch(setToolbarButton(buttonName, {
242
-                hidden: !shouldShow
233
+                hidden: false
243 234
             }));
244 235
         }
245 236
     };

Loading…
Annulla
Salva