mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
await in loop --> Promise.all()
This commit is contained in:
parent
9bdf9c500b
commit
b29287c47e
@ -35,7 +35,7 @@ export class ThemeBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async populateDerivedTheme(manifest: ThemeManifest, log: ILogItem): Promise<void> {
|
async populateDerivedTheme(manifest: ThemeManifest, log: ILogItem): Promise<void> {
|
||||||
await log.wrap("ThemeBuilder.populateThemeMap", async (l) => {
|
await log.wrap("ThemeBuilder.populateThemeMap", async () => {
|
||||||
const {manifest: baseManifest, location} = this._idToManifest.get(manifest.extends!)!;
|
const {manifest: baseManifest, location} = this._idToManifest.get(manifest.extends!)!;
|
||||||
const {cssLocation, derivedVariables, icons} = this._getSourceData(baseManifest, location, log);
|
const {cssLocation, derivedVariables, icons} = this._getSourceData(baseManifest, location, log);
|
||||||
const themeName = manifest.name;
|
const themeName = manifest.name;
|
||||||
|
@ -60,11 +60,13 @@ export class ThemeLoader {
|
|||||||
);
|
);
|
||||||
results.forEach(({ body }, i) => idToManifest.set(body.id, { manifest: body, location: manifestLocations[i] }));
|
results.forEach(({ body }, i) => idToManifest.set(body.id, { manifest: body, location: manifestLocations[i] }));
|
||||||
this._themeBuilder = new ThemeBuilder(this._platform, idToManifest, this.preferredColorScheme);
|
this._themeBuilder = new ThemeBuilder(this._platform, idToManifest, this.preferredColorScheme);
|
||||||
|
const runtimeThemePromises: Promise<void>[] = [];
|
||||||
for (let i = 0; i < results.length; ++i) {
|
for (let i = 0; i < results.length; ++i) {
|
||||||
const { body } = results[i];
|
const { body } = results[i];
|
||||||
try {
|
try {
|
||||||
if (body.extends) {
|
if (body.extends) {
|
||||||
await this._themeBuilder.populateDerivedTheme(body, log);
|
const promise = this._themeBuilder.populateDerivedTheme(body, log);
|
||||||
|
runtimeThemePromises.push(promise);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._populateThemeMap(body, manifestLocations[i], log);
|
this._populateThemeMap(body, manifestLocations[i], log);
|
||||||
@ -74,6 +76,7 @@ export class ThemeLoader {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await Promise.all(runtimeThemePromises);
|
||||||
Object.assign(this._themeMapping, this._themeBuilder.themeMapping);
|
Object.assign(this._themeMapping, this._themeBuilder.themeMapping);
|
||||||
// Add the default-theme as an additional option to the mapping
|
// Add the default-theme as an additional option to the mapping
|
||||||
const defaultThemeId = this.getDefaultTheme();
|
const defaultThemeId = this.getDefaultTheme();
|
||||||
@ -94,7 +97,7 @@ export class ThemeLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _populateThemeMap(manifest: ThemeManifest, manifestLocation: string, log: ILogItem) {
|
private _populateThemeMap(manifest: ThemeManifest, manifestLocation: string, log: ILogItem) {
|
||||||
log.wrap("populateThemeMap", (l) => {
|
log.wrap("populateThemeMap", () => {
|
||||||
/*
|
/*
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user