mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
cleanup
This commit is contained in:
parent
5bd28da4f3
commit
c87628b614
@ -67,28 +67,21 @@ async function loadOlm(olmPaths) {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// turn asset path to absolute path if it isn't already
|
||||||
// make path relative to basePath,
|
// so it can be loaded independent of base
|
||||||
// assuming it and basePath are relative to document
|
function assetAbsPath(assetPath) {
|
||||||
function relPath(path, basePath) {
|
if (!assetPath.startsWith("/")) {
|
||||||
const idx = basePath.lastIndexOf("/");
|
return new URL(assetPath, document.location.href).pathname;
|
||||||
const dir = idx === -1 ? "" : basePath.slice(0, idx);
|
}
|
||||||
const dirCount = dir.length ? dir.split("/").length : 0;
|
return assetPath;
|
||||||
return "../".repeat(dirCount) + path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadOlmWorker(config) {
|
async function loadOlmWorker(config) {
|
||||||
const workerPool = new WorkerPool(config.worker, 4);
|
const workerPool = new WorkerPool(config.worker, 4);
|
||||||
await workerPool.init();
|
await workerPool.init();
|
||||||
let olmPath = config.olm.legacyBundle;
|
|
||||||
// convert olm path to absolute path
|
|
||||||
if (!olmPath.startsWith("/")) {
|
|
||||||
olmPath = new URL(olmPath, document.location.href).pathname;
|
|
||||||
console.log("olmPath", config.olm.legacyBundle, olmPath);
|
|
||||||
}
|
|
||||||
await workerPool.sendAll({
|
await workerPool.sendAll({
|
||||||
type: "load_olm",
|
type: "load_olm",
|
||||||
path: olmPath
|
path: assetAbsPath(config.olm.legacyBundle)
|
||||||
});
|
});
|
||||||
const olmWorker = new OlmWorker(workerPool);
|
const olmWorker = new OlmWorker(workerPool);
|
||||||
return olmWorker;
|
return olmWorker;
|
||||||
|
Loading…
Reference in New Issue
Block a user