Fix olm import
This commit is contained in:
parent
44486aa62d
commit
e2aee0be81
1 changed files with 15 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue