Revert "add debouncing to selected theme"

This reverts commit ad7255efcc.
This commit is contained in:
SethBurkart123
2024-05-03 12:33:11 +10:00
parent ad7255efcc
commit be1679007e
3 changed files with 5 additions and 32 deletions
+1 -4
View File
@@ -25,17 +25,14 @@ export const ThemeCover: React.FC<ThemeCoverProps> = ({
const handleThemeClick = async () => { const handleThemeClick = async () => {
if (isEditMode) return; if (isEditMode) return;
if (downloaded) { if (downloaded) {
// move the theme from temporary storage to SEQTAs storage
await sendThemeUpdate(theme as DownloadedTheme, true) await sendThemeUpdate(theme as DownloadedTheme, true)
// remove from temp storage
await browser.runtime.sendMessage({ await browser.runtime.sendMessage({
type: 'DeleteDownloadedTheme', type: 'DeleteDownloadedTheme',
body: theme.id body: theme.id
}) })
// set it!
setTheme(theme.id); setTheme(theme.id);
} else { } else {
console.debug(theme) console.log(theme)
onThemeSelect(theme.id); onThemeSelect(theme.id);
} }
}; };
@@ -79,20 +79,10 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
useEffect(() => { useEffect(() => {
fetchThemes(); fetchThemes();
/* const interval = setInterval(() => {
console.log("Done!");
if (isLoading == true) {
fetchThemes();
} else {
clearInterval(interval);
}
}, 1000); */
}, []); }, []);
const handleThemeSelect = useCallback( const handleThemeSelect = useCallback(
async (themeId: string) => { async (themeId: string) => {
console.log(themeId === settingsState.selectedTheme);
if (themeId === settingsState.selectedTheme) { if (themeId === settingsState.selectedTheme) {
await disableTheme(); await disableTheme();
setSelectedTheme(''); setSelectedTheme('');
+3 -17
View File
@@ -1,5 +1,4 @@
import browser from 'webextension-polyfill' import browser from 'webextension-polyfill'
import { debounce } from 'lodash';
import { import {
CreateBackground, CreateBackground,
@@ -12,18 +11,13 @@ 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'; import { appendBackgroundToUI } from '../../ui/ImageBackgrounds';
import { setTheme } from '../../ui/themes/setTheme';
import { disableTheme } from '../../ui/themes/disableTheme';
export default class StorageListener { export default class StorageListener {
darkMode: any; darkMode: any;
debouncedSetTheme: any;
constructor() { constructor() {
this.darkMode = getDarkMode(); this.darkMode = getDarkMode();
this.debouncedSetTheme = debounce(this.applyTheme, 300); // 300 ms debounce period
browser.storage.onChanged.addListener(this.handleStorageChanges.bind(this)); browser.storage.onChanged.addListener(this.handleStorageChanges.bind(this));
} }
@@ -88,8 +82,8 @@ export default class StorageListener {
} }
break; break;
case 'selectedTheme': case 'theme':
this.debouncedSetTheme(changes.selectedTheme.newValue); console.log(changes.theme.newValue)
break; break;
default: default:
@@ -98,14 +92,6 @@ export default class StorageListener {
}); });
} }
applyTheme(theme: string) {
if (theme === '') {
disableTheme();
} else {
setTheme(theme);
}
}
handleSelectedColorChange(newColor: any) { handleSelectedColorChange(newColor: any) {
try { try {
updateAllColors(this.darkMode, newColor); updateAllColors(this.darkMode, newColor);