mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
remove unnecesarry theme updates
This commit is contained in:
@@ -23,13 +23,6 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
|
|||||||
...prevState,
|
...prevState,
|
||||||
selectedTheme: themeId,
|
selectedTheme: themeId,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/* debounce(() => {
|
|
||||||
setSettingsState((prevState: SettingsState) => ({
|
|
||||||
...prevState,
|
|
||||||
selectedTheme: themeId,
|
|
||||||
}));
|
|
||||||
}, 50); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
@@ -99,13 +92,14 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
|
|||||||
if (selectedTheme) {
|
if (selectedTheme) {
|
||||||
await setTheme(selectedTheme.id);
|
await setTheme(selectedTheme.id);
|
||||||
setSelectedTheme(themeId);
|
setSelectedTheme(themeId);
|
||||||
//debounce(() => setSelectedTheme(selectedTheme.id), 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[settingsState.selectedTheme, themes]
|
[settingsState.selectedTheme, themes]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleThemeSelectDebounced = debounce(handleThemeSelect, 50);
|
||||||
|
|
||||||
const handleThemeDelete = useCallback(
|
const handleThemeDelete = useCallback(
|
||||||
async (themeId: string) => {
|
async (themeId: string) => {
|
||||||
try {
|
try {
|
||||||
@@ -135,7 +129,7 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
|
|||||||
theme={theme}
|
theme={theme}
|
||||||
isSelected={theme.id === settingsState.selectedTheme}
|
isSelected={theme.id === settingsState.selectedTheme}
|
||||||
isEditMode={isEditMode}
|
isEditMode={isEditMode}
|
||||||
onThemeSelect={handleThemeSelect}
|
onThemeSelect={handleThemeSelectDebounced}
|
||||||
onThemeDelete={handleThemeDelete}
|
onThemeDelete={handleThemeDelete}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -147,7 +141,7 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
|
|||||||
theme={theme}
|
theme={theme}
|
||||||
isSelected={theme.id === settingsState.selectedTheme}
|
isSelected={theme.id === settingsState.selectedTheme}
|
||||||
isEditMode={isEditMode}
|
isEditMode={isEditMode}
|
||||||
onThemeSelect={handleThemeSelect}
|
onThemeSelect={handleThemeSelectDebounced}
|
||||||
onThemeDelete={handleThemeDelete}
|
onThemeDelete={handleThemeDelete}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
import sendThemeUpdate from '../../utils/sendThemeUpdate';
|
|
||||||
|
|
||||||
export const removeTheme = async (theme: CustomTheme) => {
|
export const removeTheme = async (theme: CustomTheme) => {
|
||||||
// Remove custom CSS
|
// Remove custom CSS
|
||||||
@@ -20,6 +19,4 @@ export const removeTheme = async (theme: CustomTheme) => {
|
|||||||
customImageVariables.forEach((variableName) => {
|
customImageVariables.forEach((variableName) => {
|
||||||
document.documentElement.style.removeProperty('--' + variableName);
|
document.documentElement.style.removeProperty('--' + variableName);
|
||||||
});
|
});
|
||||||
|
|
||||||
sendThemeUpdate();
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import localforage from 'localforage';
|
|||||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||||
import { applyTheme } from './applyTheme';
|
import { applyTheme } from './applyTheme';
|
||||||
import { removeTheme } from './removeTheme';
|
import { removeTheme } from './removeTheme';
|
||||||
import sendThemeUpdate from '../../utils/sendThemeUpdate';
|
|
||||||
|
|
||||||
|
|
||||||
export const setTheme = async (themeId: string) => {
|
export const setTheme = async (themeId: string) => {
|
||||||
@@ -39,7 +38,6 @@ export const setTheme = async (themeId: string) => {
|
|||||||
originalSelectedColor: originalSelectedColor.selectedColor
|
originalSelectedColor: originalSelectedColor.selectedColor
|
||||||
});
|
});
|
||||||
|
|
||||||
sendThemeUpdate();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error setting theme:', error);
|
console.error('Error setting theme:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
} from '../../../SEQTA';
|
} from '../../../SEQTA';
|
||||||
import { updateBgDurations } from '../../ui/Animation';
|
import { updateBgDurations } from '../../ui/Animation';
|
||||||
import { getDarkMode, updateAllColors } from '../../ui/colors/Manager';
|
import { getDarkMode, updateAllColors } from '../../ui/colors/Manager';
|
||||||
import { appendBackgroundToUI } from '../../ui/ImageBackgrounds';
|
|
||||||
|
|
||||||
|
|
||||||
export default class StorageListener {
|
export default class StorageListener {
|
||||||
@@ -83,7 +82,7 @@ export default class StorageListener {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'theme':
|
case 'theme':
|
||||||
console.log(changes.theme.newValue)
|
console.debug(changes.theme.newValue)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user