Skip to content

Commit eb40de4

Browse files
committed
Make sure we load the config before trying to redirect to a mobile page
Signed-off-by: Travis Ralston <travpc@gmail.com>
1 parent 67ca151 commit eb40de4

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

‎src/vector/index.js‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,27 @@ async function loadApp() {
246246
// set the platform for react sdk (our Platform object automatically picks the right one)
247247
PlatformPeg.set(new Platform());
248248

249+
// Load the config file. First try to load up a domain-specific config of the
250+
// form "config.$domain.json" and if that fails, fall back to config.json.
251+
let configJson;
252+
let configError;
253+
try {
254+
try {
255+
configJson = await getConfig(`config.${document.domain}.json`);
256+
// 404s succeed with an empty json config, so check that there are keys
257+
if (Object.keys(configJson).length === 0) {
258+
throw new Error(); // throw to enter the catch
259+
}
260+
} catch (e) {
261+
configJson = await getConfig("config.json");
262+
}
263+
} catch (e) {
264+
configError = e;
265+
}
266+
SdkConfig.put(configJson);
267+
249268
// don't try to redirect to the native apps if we're
250-
// verifying a 3pid
269+
// verifying a 3pid (but after we've loaded the config)
251270
const preventRedirect = Boolean(fragparts.params.client_secret);
252271

253272
if (!preventRedirect) {
@@ -279,25 +298,6 @@ async function loadApp() {
279298
}
280299
}
281300

282-
// Load the config file. First try to load up a domain-specific config of the
283-
// form "config.$domain.json" and if that fails, fall back to config.json.
284-
let configJson;
285-
let configError;
286-
try {
287-
try {
288-
configJson = await getConfig(`config.${document.domain}.json`);
289-
// 404s succeed with an empty json config, so check that there are keys
290-
if (Object.keys(configJson).length === 0) {
291-
throw new Error(); // throw to enter the catch
292-
}
293-
} catch (e) {
294-
configJson = await getConfig("config.json");
295-
}
296-
} catch (e) {
297-
configError = e;
298-
}
299-
SdkConfig.put(configJson);
300-
301301
// as quickly as we possibly can, set a default theme...
302302
const styleElements = Object.create(null);
303303
let a;

0 commit comments

Comments
 (0)