Skip to content

Commit 92d8ee3

Browse files
committed
merge initial-load.ts into init.ts as its no longer used by Jitsi
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 1f94b25 commit 92d8ee3

3 files changed

Lines changed: 43 additions & 60 deletions

File tree

‎src/vector/app.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig";
4141
import {setTheme} from "matrix-react-sdk/src/theme";
4242

4343
import CallHandler from 'matrix-react-sdk/src/CallHandler';
44-
import {loadConfig, preparePlatform} from "./initial-load";
45-
import {loadLanguage, loadOlm} from "./init";
44+
import {loadConfig, preparePlatform, loadLanguage, loadOlm} from "./init";
4645

4746
let lastLocationHashSet = null;
4847

‎src/vector/init.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,50 @@ import Olm from 'olm';
2323

2424
import * as languageHandler from 'matrix-react-sdk/src/languageHandler';
2525
import SettingsStore from "matrix-react-sdk/src/settings/SettingsStore";
26+
import ElectronPlatform from "./platform/ElectronPlatform";
27+
import WebPlatform from "./platform/WebPlatform";
28+
import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg';
29+
import SdkConfig from "matrix-react-sdk/src/SdkConfig";
2630

2731

32+
export function preparePlatform() {
33+
if ((<any>window).ipcRenderer) {
34+
console.log("Using Electron platform");
35+
const plaf = new ElectronPlatform();
36+
PlatformPeg.set(plaf);
37+
} else {
38+
console.log("Using Web platform");
39+
PlatformPeg.set(new WebPlatform());
40+
}
41+
}
42+
43+
export async function loadConfig(): Promise<{configError?: Error, configSyntaxError: boolean}> {
44+
const platform = PlatformPeg.get();
45+
46+
let configJson;
47+
let configError;
48+
let configSyntaxError = false;
49+
try {
50+
configJson = await platform.getConfig();
51+
} catch (e) {
52+
configError = e;
53+
54+
if (e && e.err && e.err instanceof SyntaxError) {
55+
console.error("SyntaxError loading config:", e);
56+
configSyntaxError = true;
57+
configJson = {}; // to prevent errors between here and loading CSS for the error box
58+
}
59+
}
60+
61+
// XXX: We call this twice, once here and once in MatrixChat as a prop. We call it here to ensure
62+
// granular settings are loaded correctly and to avoid duplicating the override logic for the theme.
63+
//
64+
// Note: this isn't called twice for some wrappers, like the Jitsi wrapper.
65+
SdkConfig.put(configJson);
66+
67+
return {configError, configSyntaxError};
68+
}
69+
2870
export function loadOlm(): Promise<void> {
2971
/* Load Olm. We try the WebAssembly version first, and then the legacy,
3072
* asm.js version if that fails. For this reason we need to wait for this

‎src/vector/initial-load.ts‎

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)