fixed theme selected dissapearing after reload in menu

This commit is contained in:
SethBurkart123
2023-11-22 09:39:29 +11:00
parent 6dd75462b3
commit 1d01ccfc40
+6 -2
View File
@@ -22,14 +22,18 @@ const ThemeSelector = ({ selectedType, setSelectedType, isEditMode }: ThemeSelec
useEffect(() => { useEffect(() => {
const initializeThemes = async () => { const initializeThemes = async () => {
const downloaded = (await listThemes()).themes; const downloaded = (await listThemes());
const initializedThemes = themesList.map(theme => ({ const initializedThemes = themesList.map(theme => ({
...theme, ...theme,
isDownloaded: downloaded.includes(theme.name), isDownloaded: downloaded.themes.includes(theme.name),
isLoading: false isLoading: false
})); }));
if (downloaded.selectedTheme !== '') {
setEnabledThemeName(downloaded.selectedTheme);
}
initializedThemes.sort((a, b) => Number(b.isDownloaded) - Number(a.isDownloaded)); initializedThemes.sort((a, b) => Number(b.isDownloaded) - Number(a.isDownloaded));
setThemes(initializedThemes); setThemes(initializedThemes);