From 211a45b6887c7923089b0f331e4a6e1657bcd44b Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 22 Dec 2024 15:07:20 +0200 Subject: [PATCH] improve robustness of appearance tab --- src/components/settings_modal/tabs/appearance_tab.js | 11 ++++++++++- .../settings_modal/tabs/theme_tab/theme_tab.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/settings_modal/tabs/appearance_tab.js b/src/components/settings_modal/tabs/appearance_tab.js index 7ea4a09a..927b402d 100644 --- a/src/components/settings_modal/tabs/appearance_tab.js +++ b/src/components/settings_modal/tabs/appearance_tab.js @@ -119,7 +119,16 @@ const AppearanceTab = { updateIndex('theme').then(themes => { themes.forEach(([key, themePromise]) => themePromise.then(data => { - this.availableThemesV2.push({ key, data, name: data.name, version: 'v2' }) + console.log('DEBUG', data) + if (!data) { + console.warn(`Theme with key ${key} is empty or malformed`) + } else if (Array.isArray(data)) { + console.warn(`Theme with key ${key} is a v1 theme and should be moved to static/palettes/index.json`) + } else if (!data.source && !data.theme) { + console.warn(`Theme with key ${key} is malformed`) + } else { + this.availableThemesV2.push({ key, data, name: data.name, version: 'v2' }) + } })) }) diff --git a/src/components/settings_modal/tabs/theme_tab/theme_tab.js b/src/components/settings_modal/tabs/theme_tab/theme_tab.js index e534a777..80768fe7 100644 --- a/src/components/settings_modal/tabs/theme_tab/theme_tab.js +++ b/src/components/settings_modal/tabs/theme_tab/theme_tab.js @@ -133,7 +133,7 @@ export default { Object .values(themesIndex) .forEach(themeFunc => { - themeFunc().then(themeData => this.availableStyles.push(themeData)) + themeFunc().then(themeData => themeData && this.availableStyles.push(themeData)) }) }) },