From 92d8ee355d7767f9b4a5f4bbefe1148ab809894d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 25 Mar 2020 14:32:37 +0000 Subject: [PATCH] merge initial-load.ts into init.ts as its no longer used by Jitsi Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/app.js | 3 +- src/vector/init.ts | 42 +++++++++++++++++++++++++++ src/vector/initial-load.ts | 58 -------------------------------------- 3 files changed, 43 insertions(+), 60 deletions(-) delete mode 100644 src/vector/initial-load.ts diff --git a/src/vector/app.js b/src/vector/app.js index 6099b3aa..b7ad872a 100644 --- a/src/vector/app.js +++ b/src/vector/app.js @@ -41,8 +41,7 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig"; import {setTheme} from "matrix-react-sdk/src/theme"; import CallHandler from 'matrix-react-sdk/src/CallHandler'; -import {loadConfig, preparePlatform} from "./initial-load"; -import {loadLanguage, loadOlm} from "./init"; +import {loadConfig, preparePlatform, loadLanguage, loadOlm} from "./init"; let lastLocationHashSet = null; diff --git a/src/vector/init.ts b/src/vector/init.ts index 8ec45df0..04db8801 100644 --- a/src/vector/init.ts +++ b/src/vector/init.ts @@ -23,8 +23,50 @@ import Olm from 'olm'; import * as languageHandler from 'matrix-react-sdk/src/languageHandler'; import SettingsStore from "matrix-react-sdk/src/settings/SettingsStore"; +import ElectronPlatform from "./platform/ElectronPlatform"; +import WebPlatform from "./platform/WebPlatform"; +import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg'; +import SdkConfig from "matrix-react-sdk/src/SdkConfig"; +export function preparePlatform() { + if ((window).ipcRenderer) { + console.log("Using Electron platform"); + const plaf = new ElectronPlatform(); + PlatformPeg.set(plaf); + } else { + console.log("Using Web platform"); + PlatformPeg.set(new WebPlatform()); + } +} + +export async function loadConfig(): Promise<{configError?: Error, configSyntaxError: boolean}> { + const platform = PlatformPeg.get(); + + let configJson; + let configError; + let configSyntaxError = false; + try { + configJson = await platform.getConfig(); + } catch (e) { + configError = e; + + if (e && e.err && e.err instanceof SyntaxError) { + console.error("SyntaxError loading config:", e); + configSyntaxError = true; + configJson = {}; // to prevent errors between here and loading CSS for the error box + } + } + + // 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); + + return {configError, configSyntaxError}; +} + export function loadOlm(): Promise { /* Load Olm. We try the WebAssembly version first, and then the legacy, * asm.js version if that fails. For this reason we need to wait for this diff --git a/src/vector/initial-load.ts b/src/vector/initial-load.ts deleted file mode 100644 index 7bd73c5a..00000000 --- a/src/vector/initial-load.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2020 New Vector Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import ElectronPlatform from './platform/ElectronPlatform'; -import WebPlatform from './platform/WebPlatform'; -import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg'; -import SdkConfig from "matrix-react-sdk/src/SdkConfig"; - -export function preparePlatform() { - if ((window).ipcRenderer) { - console.log("Using Electron platform"); - const plaf = new ElectronPlatform(); - PlatformPeg.set(plaf); - } else { - console.log("Using Web platform"); - PlatformPeg.set(new WebPlatform()); - } -} - -export async function loadConfig(): Promise<{configError?: Error, configSyntaxError: boolean}> { - const platform = PlatformPeg.get(); - - let configJson; - let configError; - let configSyntaxError = false; - try { - configJson = await platform.getConfig(); - } catch (e) { - configError = e; - - if (e && e.err && e.err instanceof SyntaxError) { - console.error("SyntaxError loading config:", e); - configSyntaxError = true; - configJson = {}; // to prevent errors between here and loading CSS for the error box - } - } - - // 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); - - return {configError, configSyntaxError}; -}