diff --git a/src/vector/app.js b/src/vector/app.js index 327690e647..b03f550394 100644 --- a/src/vector/app.js +++ b/src/vector/app.js @@ -128,7 +128,7 @@ function onTokenLoginCompleted() { window.location.href = formatted; } -export async function loadApp(fragParams: {}, acceptBrowser: boolean) { +export async function loadApp(fragParams: {}, acceptBrowser: boolean, configError: Error) { // XXX: the way we pass the path to the worker script from webpack via html in body's dataset is a hack // but alternatives seem to require changing the interface to passing Workers to js-sdk const vectorIndexeddbWorkerScript = document.body.dataset.vectorIndexeddbWorkerScript; @@ -146,9 +146,6 @@ export async function loadApp(fragParams: {}, acceptBrowser: boolean) { const platform = PlatformPeg.get(); - // Load the config from the platform - const configError = await loadConfig(); - // Load language after loading config.json so that settingsDefaults.language can be applied await loadLanguage(); diff --git a/src/vector/index.ts b/src/vector/index.ts index 5829b3f576..23dc04705e 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -21,7 +21,7 @@ limitations under the License. // Require common CSS here; this will make webpack process it into bundle.css. // Our own CSS (which is themed) is imported via separate webpack entry points // in webpack.config.js -import {preparePlatform} from "./init"; +import {loadConfig, preparePlatform} from "./init"; require('gfm.css/gfm.css'); require('highlight.js/styles/github.css'); @@ -112,7 +112,8 @@ async function start() { // set the platform for react sdk preparePlatform(); - + // load config requires the platform to be ready + const loadConfigPromise = loadConfig(); const loadOlmPromise = loadOlm(); await loadSkin(); @@ -125,8 +126,11 @@ async function start() { // await things starting successfully await loadOlmPromise; + + const configError = await loadConfigPromise; + // Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to // run on the components. - await loadApp(fragparts.params, acceptBrowser); + await loadApp(fragparts.params, acceptBrowser, configError); } start(); diff --git a/src/vector/init.ts b/src/vector/init.ts index 8b8a62bb3c..04c847ff5e 100644 --- a/src/vector/init.ts +++ b/src/vector/init.ts @@ -138,12 +138,12 @@ export async function loadSkin() { console.log("Skin loaded!"); } -export async function loadApp(fragParams: {}, acceptBrowser: boolean) { +export async function loadApp(fragParams: {}, acceptBrowser: boolean, configError: Error) { // load app.js async so that its code is not executed immediately and we can catch any exceptions const module = await import( /* webpackChunkName: "riot-web-app" */ /* webpackPreload: true */ "./app"); - window.matrixChat = ReactDOM.render(await module.loadApp(fragParams, acceptBrowser), + window.matrixChat = ReactDOM.render(await module.loadApp(fragParams, acceptBrowser, configError), document.getElementById('matrixchat')); }