remove unnecesarry theme updates

This commit is contained in:
SethBurkart123
2024-05-06 11:39:21 +10:00
parent 23e6eac16c
commit 3db51fb6d5
4 changed files with 5 additions and 17 deletions
+4 -10
View File
@@ -23,13 +23,6 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
...prevState,
selectedTheme: themeId,
}));
/* debounce(() => {
setSettingsState((prevState: SettingsState) => ({
...prevState,
selectedTheme: themeId,
}));
}, 50); */
}
useImperativeHandle(ref, () => ({
@@ -99,13 +92,14 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
if (selectedTheme) {
await setTheme(selectedTheme.id);
setSelectedTheme(themeId);
//debounce(() => setSelectedTheme(selectedTheme.id), 100);
}
}
},
[settingsState.selectedTheme, themes]
);
const handleThemeSelectDebounced = debounce(handleThemeSelect, 50);
const handleThemeDelete = useCallback(
async (themeId: string) => {
try {
@@ -135,7 +129,7 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
theme={theme}
isSelected={theme.id === settingsState.selectedTheme}
isEditMode={isEditMode}
onThemeSelect={handleThemeSelect}
onThemeSelect={handleThemeSelectDebounced}
onThemeDelete={handleThemeDelete}
/>
))}
@@ -147,7 +141,7 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
theme={theme}
isSelected={theme.id === settingsState.selectedTheme}
isEditMode={isEditMode}
onThemeSelect={handleThemeSelect}
onThemeSelect={handleThemeSelectDebounced}
onThemeDelete={handleThemeDelete}
/>
))}