diff --git a/app/src/data/customThemes.ts b/app/src/data/customThemes.ts index 60affe63bc..e3ce9e1722 100644 --- a/app/src/data/customThemes.ts +++ b/app/src/data/customThemes.ts @@ -37,22 +37,28 @@ async function loadCustomThemesInternal() { const { customThemes = [] } = getCustomThemesConfigFromLs() || {}; const ctManifestArr: CustomThemeManifest[] = []; if (customThemes.length > 0) { - await Promise.all( + const ctManifestArrLoaded = await Promise.all( customThemes.map(async (themeUrl) => { const themeManifestUrl = `${themeUrl}/${THEME_MANIFEST_FILE}`; return fetch(themeManifestUrl) - .then(async (r) => { - const tmJson: { css: string[]; settings: null | string, id: string, name: string, propsOverride?: TPropEditorTypeOverride } = await r.json(); - const { id, name, css, settings, propsOverride } = tmJson; - const loadedSettings = settings ? await loadSettings(convertRelUrlToAbs(settings, themeUrl)) : null; - await loadCssArr(css.map((cssRel) => convertRelUrlToAbs(cssRel, themeUrl))); - ctManifestArr.push({ id, name, css, settings: loadedSettings, propsOverride }); - }) - .catch((err) => { - console.error(`Unable to load custom theme from "${themeManifestUrl}"`, err); - }); + .then(async (r) => { + const tmJson: { css: string[]; settings: null | string, id: string, name: string, propsOverride?: TPropEditorTypeOverride } = await r.json(); + const { id, name, css, settings, propsOverride } = tmJson; + const loadedSettings = settings ? await loadSettings(convertRelUrlToAbs(settings, themeUrl)) : null; + await loadCssArr(css.map((cssRel) => convertRelUrlToAbs(cssRel, themeUrl))); + return { id, name, css, settings: loadedSettings, propsOverride }; + }) + .catch((err) => { + console.error(`Unable to load custom theme from "${themeManifestUrl}"`, err); + return undefined; + }); }), ); + ctManifestArrLoaded.forEach((item: CustomThemeManifest | undefined) => { + if (item) { + ctManifestArr.push(item); + } + }); } return ctManifestArr; }