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:
RMidhunSuresh 2022-05-23 12:45:32 +05:30
parent 8b2299852e
commit 4474458f4b
1 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@ export class ThemeLoader {
return Object.keys(this._themeMapping);
}
async getActiveTheme(): Promise<string|undefined> {
async getActiveTheme(): Promise<string> {
// check if theme is set via settings
let theme = await this._platform.settingsStorage.getString("theme");
if (theme) {
@ -70,6 +70,6 @@ export class ThemeLoader {
} else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
return this._platform.config["defaultTheme"].light;
}
return undefined;
throw new Error("Cannot find active theme!");
}
}