diff --git a/src/matrix-utils.js b/src/matrix-utils.js index b1201f9..a5a0683 100644 --- a/src/matrix-utils.js +++ b/src/matrix-utils.js @@ -4,6 +4,8 @@ import { GroupCallType, } from "matrix-js-sdk/src/browser-index"; import IndexedDBWorker from "./IndexedDBWorker?worker"; +import olmJsPath from "olm/olm.js?url"; +import olmWasmPath from "olm/olm.wasm?url"; export const defaultHomeserver = import.meta.env.VITE_DEFAULT_HOMESERVER || @@ -26,7 +28,20 @@ function waitForSync(client) { }); } +function addScript(src) { + return new Promise((resolve, reject) => { + const script = document.createElement("script"); + script.setAttribute("src", src); + script.onload = resolve; + script.onerror = reject; + document.body.appendChild(script); + }); +} + export async function initClient(clientOptions) { + await addScript(olmJsPath); + await window.Olm.init({ locateFile: () => olmWasmPath }); + let indexedDB; try {