mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-22 18:21:39 +01:00
Add more logging
This commit is contained in:
parent
51a837d459
commit
d08cfe3a29
@ -188,8 +188,9 @@ export class Platform {
|
|||||||
this._config.push
|
this._config.push
|
||||||
);
|
);
|
||||||
const manifests = this.config["themeManifests"];
|
const manifests = this.config["themeManifests"];
|
||||||
await this._themeLoader?.init(manifests);
|
await this._themeLoader?.init(manifests, log);
|
||||||
const { themeName, themeVariant } = await this._themeLoader.getActiveTheme();
|
const { themeName, themeVariant } = await this._themeLoader.getActiveTheme();
|
||||||
|
log.log({ l: "Active theme", name: themeName, variant: themeVariant });
|
||||||
this._themeLoader?.setTheme(themeName, themeVariant, log);
|
this._themeLoader?.setTheme(themeName, themeVariant, log);
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -55,7 +55,8 @@ export class ThemeLoader {
|
|||||||
this._platform = platform;
|
this._platform = platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(manifestLocations: string[]): Promise<void> {
|
async init(manifestLocations: string[], log?: ILogItem): Promise<void> {
|
||||||
|
await this._platform.logger.wrapOrRun(log, "ThemeLoader.init", async (log) => {
|
||||||
this._themeMapping = {};
|
this._themeMapping = {};
|
||||||
for (const manifestLocation of manifestLocations) {
|
for (const manifestLocation of manifestLocations) {
|
||||||
const { body } = await this._platform
|
const { body } = await this._platform
|
||||||
@ -65,11 +66,13 @@ export class ThemeLoader {
|
|||||||
cache: true,
|
cache: true,
|
||||||
})
|
})
|
||||||
.response();
|
.response();
|
||||||
this._populateThemeMap(body);
|
this._populateThemeMap(body, log);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _populateThemeMap(manifest) {
|
private _populateThemeMap(manifest, log: ILogItem) {
|
||||||
|
log.wrap("populateThemeMap", (l) => {
|
||||||
/*
|
/*
|
||||||
After build has finished, the source section of each theme manifest
|
After build has finished, the source section of each theme manifest
|
||||||
contains `built-assets` which is a mapping from the theme-id to
|
contains `built-assets` which is a mapping from the theme-id to
|
||||||
@ -129,6 +132,10 @@ export class ThemeLoader {
|
|||||||
this._themeMapping["Default"] = { id: "default", cssLocation: themeDetails.cssLocation };
|
this._themeMapping["Default"] = { id: "default", cssLocation: themeDetails.cssLocation };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
l.log({ l: "Default Theme", theme: defaultThemeId});
|
||||||
|
l.log({ l: "Preferred colorscheme", scheme: this.preferredColorScheme === ColorSchemePreference.Dark ? "dark" : "light" });
|
||||||
|
l.log({ l: "Result", themeMapping: this._themeMapping });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTheme(themeName: string, themeVariant?: "light" | "dark" | "default", log?: ILogItem) {
|
setTheme(themeName: string, themeVariant?: "light" | "dark" | "default", log?: ILogItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user