move config loading into index for parallelism

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/13095/head
Michael Telatynski 2020-04-08 16:12:36 +01:00
parent 43357fe842
commit 2c5664b76e
3 changed files with 10 additions and 9 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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'));
}