diff --git a/src/interface/components/ThemeSelector.tsx b/src/interface/components/ThemeSelector.tsx index 4f4439d1..5adef606 100644 --- a/src/interface/components/ThemeSelector.tsx +++ b/src/interface/components/ThemeSelector.tsx @@ -20,7 +20,6 @@ interface ThemeSelectorProps { const ThemeSelector: ForwardRefExoticComponent & RefAttributes> = forwardRef(({ isEditMode = false }, ref) => { const [themes, setThemes] = useState[]>([]); - const [downloadedThemes, setDownloadedThemes] = useState([]); const [isLoading, setIsLoading] = useState(true); const [isDragging, setIsDragging] = useState(false); const [tempTheme, setTempTheme] = useState(null); @@ -82,19 +81,10 @@ const ThemeSelector: ForwardRefExoticComponent & const fetchThemes = async () => { try { const { themes, selectedTheme } = await listThemes(); - const tempDownloadedThemes = await getDownloadedThemes(); + let tempDownloadedThemes = await getDownloadedThemes(); setThemes(themes); - //setDownloadedThemes(tempDownloadedThemes); setSelectedTheme(selectedTheme ? selectedTheme : ''); - - console.log(tempDownloadedThemes) - - tempDownloadedThemes.forEach(async (theme) => { - console.log('Updating theme:', theme) - await sendThemeUpdate(theme as DownloadedTheme, true, false) - DeleteDownloadedTheme(theme.id); - }); const matchingThemes = themes.filter(theme => tempDownloadedThemes.some(downloadedTheme => downloadedTheme.id === theme.id) @@ -103,13 +93,14 @@ const ThemeSelector: ForwardRefExoticComponent & if (matchingThemes.length > 0) { matchingThemes.forEach((theme) => { DeleteDownloadedTheme(theme.id); - - setDownloadedThemes( - downloadedThemes.filter(downloadedTheme => downloadedTheme.id !== theme.id) - ) + tempDownloadedThemes = tempDownloadedThemes.filter(downloadedTheme => downloadedTheme.id !== theme.id); }) } + tempDownloadedThemes.forEach(async (theme) => { + await sendThemeUpdate(theme as DownloadedTheme, true, false) + DeleteDownloadedTheme(theme.id); + }); } catch (error) { console.error('Error fetching themes:', error); } finally { @@ -141,17 +132,9 @@ const ThemeSelector: ForwardRefExoticComponent & const handleThemeDelete = useCallback( async (themeId: string) => { - console.log(themeId, downloadedThemes) try { - if (downloadedThemes.some((theme) => theme.id === themeId)) { - console.log('Deleting downloaded theme:', themeId) - DeleteDownloadedTheme(themeId); - setDownloadedThemes((prevThemes) => prevThemes.filter((theme) => theme.id !== themeId)); - } else { - console.log('False') - await deleteTheme(themeId); - setThemes((prevThemes) => prevThemes.filter((theme) => theme.id !== themeId)); - } + await deleteTheme(themeId); + setThemes((prevThemes) => prevThemes.filter((theme) => theme.id !== themeId)); if (themeId === settingsState.selectedTheme) { setSelectedTheme('') disableTheme(); @@ -240,25 +223,13 @@ const ThemeSelector: ForwardRefExoticComponent & /> ))} - {downloadedThemes.map((theme) => ( - - ))} - {tempTheme && (
)} - {downloadedThemes.length + themes.length > 0 &&
0 &&
} diff --git a/src/seqta/ui/themes/downloadTheme.ts b/src/seqta/ui/themes/downloadTheme.ts index 6f384d8a..7c3cad69 100644 --- a/src/seqta/ui/themes/downloadTheme.ts +++ b/src/seqta/ui/themes/downloadTheme.ts @@ -15,7 +15,6 @@ type ThemeContent = { }; export const StoreDownloadTheme = async (theme: { themeContent: Theme }) => { - console.log(theme.themeContent.id); if (!theme.themeContent.id) return; const themeContent = await fetch(`https://raw.githubusercontent.com/BetterSEQTA/BetterSEQTA-Themes/main/store/themes/${theme.themeContent.id}/theme.json`); diff --git a/src/seqta/utils/listeners/MessageListener.ts b/src/seqta/utils/listeners/MessageListener.ts index 177344bd..40a728b0 100644 --- a/src/seqta/utils/listeners/MessageListener.ts +++ b/src/seqta/utils/listeners/MessageListener.ts @@ -93,7 +93,12 @@ export class MessageHandler { return true; case 'CloseThemeCreator': - CloseThemeCreator(); + try { + CloseThemeCreator(); + } catch (error) { + console.error('Error closing theme creator:', error); + sendResponse({ status: 'error' }); + } sendResponse({ status: 'success' }); break;