Explorar el Código

rn,config: create a fake config if we cannot load one on the welcome page

We try to load the configuration with every room change, even when there is no
room. There is a bad (corner) case: when we have no config cached (first boot or
wiped app data). In such case the user is trapped in an infinite loop because we
require the config to show the welcome page, oh well.

Pretend we have a configuration by creating the most minimal one to at least get
to the welcome page.
master
Saúl Ibarra Corretgé hace 6 años
padre
commit
3cc181a2e5
Se han modificado 2 ficheros con 32 adiciones y 2 borrados
  1. 9
    2
      react/features/app/actions.js
  2. 23
    0
      react/features/base/config/functions.any.js

+ 9
- 2
react/features/app/actions.js Ver fichero

@@ -5,6 +5,7 @@ import type { Dispatch } from 'redux';
5 5
 import { setRoom } from '../base/conference';
6 6
 import {
7 7
     configWillLoad,
8
+    createFakeConfig,
8 9
     loadConfigError,
9 10
     restoreConfig,
10 11
     setConfig,
@@ -101,9 +102,15 @@ export function appNavigate(uri: ?string) {
101 102
                 config = restoreConfig(baseURL);
102 103
 
103 104
                 if (!config) {
104
-                    dispatch(loadConfigError(error, locationURL));
105
+                    if (room) {
106
+                        dispatch(loadConfigError(error, locationURL));
105 107
 
106
-                    return;
108
+                        return;
109
+                    }
110
+
111
+                    // If there is no room (we are on the welcome page), don't fail, just create a fake one.
112
+                    logger.warn('Failed to load config but there is no room, applying a fake one');
113
+                    config = createFakeConfig(baseURL);
107 114
                 }
108 115
             }
109 116
         }

+ 23
- 0
react/features/base/config/functions.any.js Ver fichero

@@ -155,6 +155,29 @@ const WHITELISTED_KEYS = [
155 155
 export { default as getRoomName } from './getRoomName';
156 156
 export { parseURLParams };
157 157
 
158
+/**
159
+ * Create a "fake" configuration object for the given base URL. This is used in case the config
160
+ * couldn't be loaded in the welcome page, so at least we have something to try with.
161
+ *
162
+ * @param {string} baseURL - URL of the deployment for which we want the fake config.
163
+ * @returns {Object}
164
+ */
165
+export function createFakeConfig(baseURL: string) {
166
+    const url = new URL(baseURL);
167
+
168
+    return {
169
+        hosts: {
170
+            domain: url.hostname,
171
+            muc: `conference.${url.hostname}`
172
+        },
173
+        bosh: `${baseURL}http-bind`,
174
+        clientNode: 'https://jitsi.org/jitsi-meet',
175
+        p2p: {
176
+            enabled: true
177
+        }
178
+    };
179
+}
180
+
158 181
 /**
159 182
  * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
160 183
  * to React app it's better to use load config instead.

Loading…
Cancelar
Guardar