mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 11:44:40 +00:00
sync theme changes plus deleting
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|||||||
import { CustomTheme, DownloadedTheme } from '../types/CustomThemes';
|
import { CustomTheme, DownloadedTheme } from '../types/CustomThemes';
|
||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
import { ArrowUpOnSquareIcon, PencilIcon } from '@heroicons/react/24/outline';
|
import { ArrowUpOnSquareIcon, PencilIcon } from '@heroicons/react/24/outline';
|
||||||
import { sendThemeUpdate } from '../hooks/ThemeManagment';
|
import { sendThemeUpdate, setTheme } from '../hooks/ThemeManagment';
|
||||||
|
|
||||||
type ThemeCoverProps = {
|
type ThemeCoverProps = {
|
||||||
theme: Omit<CustomTheme, 'CustomImages'> | DownloadedTheme;
|
theme: Omit<CustomTheme, 'CustomImages'> | DownloadedTheme;
|
||||||
@@ -26,10 +26,11 @@ export const ThemeCover: React.FC<ThemeCoverProps> = ({
|
|||||||
if (isEditMode) return;
|
if (isEditMode) return;
|
||||||
if (downloaded) {
|
if (downloaded) {
|
||||||
await sendThemeUpdate(theme as DownloadedTheme, true)
|
await sendThemeUpdate(theme as DownloadedTheme, true)
|
||||||
browser.runtime.sendMessage({
|
await browser.runtime.sendMessage({
|
||||||
type: 'DeleteDownloadedTheme',
|
type: 'DeleteDownloadedTheme',
|
||||||
body: theme.id
|
body: theme.id
|
||||||
})
|
})
|
||||||
|
setTheme(theme.id);
|
||||||
} else {
|
} else {
|
||||||
console.log(theme)
|
console.log(theme)
|
||||||
onThemeSelect(theme.id);
|
onThemeSelect(theme.id);
|
||||||
@@ -38,7 +39,14 @@ export const ThemeCover: React.FC<ThemeCoverProps> = ({
|
|||||||
|
|
||||||
const handleDeleteClick = (e: React.MouseEvent) => {
|
const handleDeleteClick = (e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
if (downloaded) {
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
type: 'DeleteDownloadedTheme',
|
||||||
|
body: theme.id
|
||||||
|
})
|
||||||
|
} else {
|
||||||
onThemeDelete(theme.id);
|
onThemeDelete(theme.id);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleShareClick = (event: React.MouseEvent) => {
|
const handleShareClick = (event: React.MouseEvent) => {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const setTheme = async (themeId: string) => {
|
|||||||
originalSelectedColor: originalSelectedColor.selectedColor
|
originalSelectedColor: originalSelectedColor.selectedColor
|
||||||
});
|
});
|
||||||
|
|
||||||
|
browser.runtime.sendMessage({ type: 'extensionPages', info: 'themeChanged' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error setting theme:', error);
|
console.error('Error setting theme:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user