mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
getActiveTheme should never return undefined
Instead it should throw an error. This is useful for when we do setTheme(await getActiveTheme()) because setTheme expects a string.
This commit is contained in:
parent
8b2299852e
commit
4474458f4b
@ -58,7 +58,7 @@ export class ThemeLoader {
|
|||||||
return Object.keys(this._themeMapping);
|
return Object.keys(this._themeMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActiveTheme(): Promise<string|undefined> {
|
async getActiveTheme(): Promise<string> {
|
||||||
// check if theme is set via settings
|
// check if theme is set via settings
|
||||||
let theme = await this._platform.settingsStorage.getString("theme");
|
let theme = await this._platform.settingsStorage.getString("theme");
|
||||||
if (theme) {
|
if (theme) {
|
||||||
@ -70,6 +70,6 @@ export class ThemeLoader {
|
|||||||
} else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
} else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
||||||
return this._platform.config["defaultTheme"].light;
|
return this._platform.config["defaultTheme"].light;
|
||||||
}
|
}
|
||||||
return undefined;
|
throw new Error("Cannot find active theme!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user