improve robustness of appearance tab

This commit is contained in:
Henry Jameson 2024-12-22 15:07:20 +02:00
parent b172f99835
commit 211a45b688
2 changed files with 11 additions and 2 deletions

View file

@ -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' })
}
}))
})

View file

@ -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))
})
})
},