Explorar el Código

Fix TypeError: Cannot read property 'isGuest' of undefined

master
Lyubo Marinov hace 8 años
padre
commit
3c31a60b32

+ 7
- 0
react/features/base/config/reducer.js Ver fichero

58
         // The config of INITIAL_STATE is meant to override the config
58
         // The config of INITIAL_STATE is meant to override the config
59
         // downloaded from the Jitsi Meet deployment because the former contains
59
         // downloaded from the Jitsi Meet deployment because the former contains
60
         // values that are mandatory.
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
         ...INITIAL_STATE
68
         ...INITIAL_STATE
62
     };
69
     };
63
 }
70
 }

+ 1
- 7
react/features/base/lib-jitsi-meet/actions.js Ver fichero

21
     return (dispatch: Dispatch<*>) => {
21
     return (dispatch: Dispatch<*>) => {
22
         dispatch({ type: LIB_WILL_DISPOSE });
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
         // TODO Currently, lib-jitsi-meet doesn't have the functionality to
24
         // TODO Currently, lib-jitsi-meet doesn't have the functionality to
29
         // dispose itself.
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 Ver fichero

99
     // disposed of first.
99
     // disposed of first.
100
     // TODO Currently, disposeLib actually does not dispose of lib-jitsi-meet
100
     // TODO Currently, disposeLib actually does not dispose of lib-jitsi-meet
101
     // because lib-jitsi-meet does not implement such functionality.
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 Ver fichero

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

+ 9
- 18
react/features/toolbox/actions.web.js Ver fichero

172
 export function showDialPadButton(show: boolean): Function {
172
 export function showDialPadButton(show: boolean): Function {
173
     return (dispatch: Dispatch<*>) => {
173
     return (dispatch: Dispatch<*>) => {
174
         const buttonName = 'dialpad';
174
         const buttonName = 'dialpad';
175
-        const shouldShow = UIUtil.isButtonEnabled(buttonName) && show;
176
 
175
 
177
-        if (shouldShow) {
176
+        if (show && UIUtil.isButtonEnabled(buttonName)) {
178
             dispatch(setToolbarButton(buttonName, {
177
             dispatch(setToolbarButton(buttonName, {
179
                 hidden: false
178
                 hidden: false
180
             }));
179
             }));
205
 export function showSharedVideoButton(): Function {
204
 export function showSharedVideoButton(): Function {
206
     return (dispatch: Dispatch<*>) => {
205
     return (dispatch: Dispatch<*>) => {
207
         const buttonName = 'sharedvideo';
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
             dispatch(setToolbarButton(buttonName, {
210
             dispatch(setToolbarButton(buttonName, {
214
                 hidden: false
211
                 hidden: false
215
             }));
212
             }));
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
  * @param {boolean} show - Flag showing whether to show button or not.
220
  * @param {boolean} show - Flag showing whether to show button or not.
225
  * @returns {Function}
221
  * @returns {Function}
226
  */
222
  */
227
 export function showSIPCallButton(show: boolean): Function {
223
 export function showSIPCallButton(show: boolean): Function {
228
-    return (dispatch: Dispatch<*>) => {
224
+    return (dispatch: Dispatch<*>, getState: Function) => {
229
         const buttonName = 'sip';
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
                 && UIUtil.isButtonEnabled(buttonName)
229
                 && UIUtil.isButtonEnabled(buttonName)
236
-                && show
237
                 && (!config.enableUserRolesBasedOnToken
230
                 && (!config.enableUserRolesBasedOnToken
238
-                        || !APP.tokenData.isGuest);
239
-
240
-        if (shouldShow) {
231
+                    || !getState()['features/jwt'].isGuest)) {
241
             dispatch(setToolbarButton(buttonName, {
232
             dispatch(setToolbarButton(buttonName, {
242
-                hidden: !shouldShow
233
+                hidden: false
243
             }));
234
             }));
244
         }
235
         }
245
     };
236
     };

Loading…
Cancelar
Guardar