From a639fc54671c2d1a9ebfa8295aa0fa7c2bacb09b Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 6 Jun 2022 12:20:06 +0530 Subject: [PATCH] Rever to sensisble defaults --- src/platform/web/ThemeLoader.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platform/web/ThemeLoader.ts b/src/platform/web/ThemeLoader.ts index e278b9a6..86bee8af 100644 --- a/src/platform/web/ThemeLoader.ts +++ b/src/platform/web/ThemeLoader.ts @@ -157,8 +157,14 @@ export class ThemeLoader { } async getActiveTheme(): Promise<{themeName: string, themeVariant?: string}> { - const themeName = await this._platform.settingsStorage.getString("theme-name") ?? "Default"; - const themeVariant = await this._platform.settingsStorage.getString("theme-variant"); + let themeName = await this._platform.settingsStorage.getString("theme-name"); + let themeVariant = await this._platform.settingsStorage.getString("theme-variant"); + if (!themeName || !this._themeMapping[themeName]) { + themeName = "Default" in this._themeMapping ? "Default" : Object.keys(this._themeMapping)[0]; + if (!this._themeMapping[themeName][themeVariant]) { + themeVariant = "default" in this._themeMapping[themeName] ? "default" : undefined; + } + } return { themeName, themeVariant }; }