Skip to content

Commit 2c5664b

Browse files
committed
move config loading into index for parallelism
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 43357fe commit 2c5664b

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎src/vector/app.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function onTokenLoginCompleted() {
128128
window.location.href = formatted;
129129
}
130130

131-
export async function loadApp(fragParams: {}, acceptBrowser: boolean) {
131+
export async function loadApp(fragParams: {}, acceptBrowser: boolean, configError: Error) {
132132
// XXX: the way we pass the path to the worker script from webpack via html in body's dataset is a hack
133133
// but alternatives seem to require changing the interface to passing Workers to js-sdk
134134
const vectorIndexeddbWorkerScript = document.body.dataset.vectorIndexeddbWorkerScript;
@@ -146,9 +146,6 @@ export async function loadApp(fragParams: {}, acceptBrowser: boolean) {
146146

147147
const platform = PlatformPeg.get();
148148

149-
// Load the config from the platform
150-
const configError = await loadConfig();
151-
152149
// Load language after loading config.json so that settingsDefaults.language can be applied
153150
await loadLanguage();
154151

‎src/vector/index.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ limitations under the License.
2121
// Require common CSS here; this will make webpack process it into bundle.css.
2222
// Our own CSS (which is themed) is imported via separate webpack entry points
2323
// in webpack.config.js
24-
import {preparePlatform} from "./init";
24+
import {loadConfig, preparePlatform} from "./init";
2525

2626
require('gfm.css/gfm.css');
2727
require('highlight.js/styles/github.css');
@@ -112,7 +112,8 @@ async function start() {
112112

113113
// set the platform for react sdk
114114
preparePlatform();
115-
115+
// load config requires the platform to be ready
116+
const loadConfigPromise = loadConfig();
116117
const loadOlmPromise = loadOlm();
117118

118119
await loadSkin();
@@ -125,8 +126,11 @@ async function start() {
125126
// await things starting successfully
126127
await loadOlmPromise;
127128

129+
130+
const configError = await loadConfigPromise;
131+
128132
// Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
129133
// run on the components.
130-
await loadApp(fragparts.params, acceptBrowser);
134+
await loadApp(fragparts.params, acceptBrowser, configError);
131135
}
132136
start();

‎src/vector/init.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ export async function loadSkin() {
138138
console.log("Skin loaded!");
139139
}
140140

141-
export async function loadApp(fragParams: {}, acceptBrowser: boolean) {
141+
export async function loadApp(fragParams: {}, acceptBrowser: boolean, configError: Error) {
142142
// load app.js async so that its code is not executed immediately and we can catch any exceptions
143143
const module = await import(
144144
/* webpackChunkName: "riot-web-app" */
145145
/* webpackPreload: true */
146146
"./app");
147-
window.matrixChat = ReactDOM.render(await module.loadApp(fragParams, acceptBrowser),
147+
window.matrixChat = ReactDOM.render(await module.loadApp(fragParams, acceptBrowser, configError),
148148
document.getElementById('matrixchat'));
149149
}

0 commit comments

Comments
 (0)