mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-22 10:11:39 +01:00
Make code more readable
This commit is contained in:
parent
5d63069f31
commit
86fec8bf0e
@ -334,8 +334,7 @@ export class Platform {
|
||||
|
||||
async replaceStylesheet(newPath, log) {
|
||||
const error = await this.logger.wrapOrRun(log, { l: "replaceStylesheet", location: newPath, }, async (l) => {
|
||||
let resolve, error;
|
||||
const promise = new Promise(r => resolve = r);
|
||||
let error;
|
||||
const head = document.querySelector("head");
|
||||
// remove default theme
|
||||
document.querySelectorAll(".theme").forEach(e => e.remove());
|
||||
@ -345,6 +344,7 @@ export class Platform {
|
||||
styleTag.rel = "stylesheet";
|
||||
styleTag.type = "text/css";
|
||||
styleTag.className = "theme";
|
||||
const promise = new Promise(resolve => {
|
||||
styleTag.onerror = () => {
|
||||
error = new Error(`Failed to load stylesheet from ${newPath}`);
|
||||
l.catch(error);
|
||||
@ -353,6 +353,7 @@ export class Platform {
|
||||
styleTag.onload = () => {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
head.appendChild(styleTag);
|
||||
await promise;
|
||||
return error;
|
||||
|
Loading…
x
Reference in New Issue
Block a user