clean up loadConfig
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
e267086a17
commit
7633009ddb
2 changed files with 49 additions and 47 deletions
|
@ -102,6 +102,7 @@ async function start() {
|
|||
/* webpackPreload: true */
|
||||
"./init");
|
||||
|
||||
try {
|
||||
await settled(rageshakePromise); // give rageshake a chance to load/fail
|
||||
|
||||
const fragparts = parseQsFromFragment(window.location);
|
||||
|
@ -129,8 +130,14 @@ async function start() {
|
|||
// load config requires the platform to be ready
|
||||
const loadConfigPromise = loadConfig();
|
||||
|
||||
let configError;
|
||||
try {
|
||||
// await config here
|
||||
const configError = await loadConfigPromise;
|
||||
await loadConfigPromise;
|
||||
} catch (err) {
|
||||
configError = err;
|
||||
}
|
||||
|
||||
// Load language after loading config.json so that settingsDefaults.language can be applied
|
||||
const loadLanguagePromise = loadLanguage();
|
||||
// as quickly as we possibly can, set a default theme...
|
||||
|
@ -147,4 +154,8 @@ async function start() {
|
|||
// run on the components.
|
||||
await loadApp(fragparts.params, acceptBrowser, configError);
|
||||
}
|
||||
start();
|
||||
start().catch(err => {
|
||||
if (!acceptBrowser) {
|
||||
alert("Incompatible browser");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -47,20 +47,11 @@ export function preparePlatform() {
|
|||
}
|
||||
|
||||
export async function loadConfig(): Promise<Error | void> {
|
||||
const platform = PlatformPeg.get();
|
||||
|
||||
let configJson;
|
||||
try {
|
||||
configJson = await platform.getConfig();
|
||||
} catch (e) {
|
||||
return e;
|
||||
} finally {
|
||||
// XXX: We call this twice, once here and once in MatrixChat as a prop. We call it here to ensure
|
||||
// granular settings are loaded correctly and to avoid duplicating the override logic for the theme.
|
||||
//
|
||||
// Note: this isn't called twice for some wrappers, like the Jitsi wrapper.
|
||||
SdkConfig.put(configJson || {});
|
||||
}
|
||||
SdkConfig.put(PlatformPeg.get().getConfig() || {});
|
||||
}
|
||||
|
||||
export function loadOlm(): Promise<void> {
|
||||
|
|
Loading…
Reference in a new issue