Remove code which loads legacy libolm

Now that we use the Rust crypto stack
(https://github.com/matrix-org/matrix-react-sdk/pull/12630), the legacy olm
library is unneeded. Remove all the dedicated cruft for loading it.

(All this crap is why matrix-sdk-crypto-wasm has to base64 its wasm artifact,
cf https://github.com/matrix-org/matrix-rust-sdk/pull/1167.)
This commit is contained in:
Richard van der Hoff 2024-06-26 16:27:14 +01:00
parent d379103352
commit 7c7cbe655a
3 changed files with 5 additions and 70 deletions

View file

@ -105,7 +105,6 @@ async function start(): Promise<void> {
rageshakePromise,
setupLogStorage,
preparePlatform,
loadOlm,
loadConfig,
loadLanguage,
loadTheme,
@ -143,7 +142,6 @@ async function start(): Promise<void> {
}
}
const loadOlmPromise = loadOlm();
// set the platform for react sdk
preparePlatform();
// load config requires the platform to be ready
@ -210,7 +208,6 @@ async function start(): Promise<void> {
// app load critical path starts here
// assert things started successfully
// ##################################
await loadOlmPromise;
await loadModulesPromise;
await loadThemePromise;
await loadLanguagePromise;

View file

@ -17,10 +17,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import olmWasmPath from "@matrix-org/olm/olm.wasm";
import Olm from "@matrix-org/olm";
import * as ReactDOM from "react-dom";
import * as React from "react";
import * as languageHandler from "matrix-react-sdk/src/languageHandler";
@ -76,48 +72,6 @@ export async function loadConfig(): Promise<void> {
}
}
export function loadOlm(): Promise<void> {
/* 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
* to finish before continuing to load the rest of the app. In future
* we could somehow pass a promise down to react-sdk and have it wait on
* that so olm can be loading in parallel with the rest of the app.
*
* We also need to tell the Olm js to look for its wasm file at the same
* level as index.html. It really should be in the same place as the js,
* ie. in the bundle directory, but as far as I can tell this is
* completely impossible with webpack. We do, however, use a hashed
* filename to avoid caching issues.
*/
return Olm.init({
locateFile: () => olmWasmPath,
})
.then(() => {
logger.log("Using WebAssembly Olm");
})
.catch((wasmLoadError) => {
logger.log("Failed to load Olm: trying legacy version", wasmLoadError);
return new Promise((resolve, reject) => {
const s = document.createElement("script");
s.src = "olm_legacy.js"; // XXX: This should be cache-busted too
s.onload = resolve;
s.onerror = reject;
document.body.appendChild(s);
})
.then(() => {
// Init window.Olm, ie. the one just loaded by the script tag,
// not 'Olm' which is still the failed wasm version.
return window.Olm.init();
})
.then(() => {
logger.log("Using legacy Olm");
})
.catch((legacyLoadError) => {
logger.log("Both WebAssembly and asm.js Olm failed!", legacyLoadError);
});
});
}
export async function loadLanguage(): Promise<void> {
const prefLang = SettingsStore.getValue("language", null, /*excludeDefault=*/ true);
let langs: string[] = [];