浏览代码

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.
j8
Saúl Ibarra Corretgé 6 年前
父节点
当前提交
3cc181a2e5
共有 2 个文件被更改,包括 32 次插入2 次删除
  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 查看文件

5
 import { setRoom } from '../base/conference';
5
 import { setRoom } from '../base/conference';
6
 import {
6
 import {
7
     configWillLoad,
7
     configWillLoad,
8
+    createFakeConfig,
8
     loadConfigError,
9
     loadConfigError,
9
     restoreConfig,
10
     restoreConfig,
10
     setConfig,
11
     setConfig,
101
                 config = restoreConfig(baseURL);
102
                 config = restoreConfig(baseURL);
102
 
103
 
103
                 if (!config) {
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 查看文件

155
 export { default as getRoomName } from './getRoomName';
155
 export { default as getRoomName } from './getRoomName';
156
 export { parseURLParams };
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
  * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
182
  * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
160
  * to React app it's better to use load config instead.
183
  * to React app it's better to use load config instead.

正在加载...
取消
保存