feat: add active theme handling in theme deletion modals

This commit is contained in:
Hachi-R 2025-01-30 03:00:55 -03:00
parent 61d4910b6d
commit 13eeb2cee7
3 changed files with 15 additions and 0 deletions

View File

@ -69,6 +69,7 @@ export const ThemeCard = ({ theme, onListUpdated }: ThemeCardProps) => {
onThemeDeleted={onListUpdated}
themeId={theme.id}
themeName={theme.name}
isActive={theme.isActive}
/>
<div

View File

@ -2,6 +2,7 @@ import { Button } from "@renderer/components/button/button";
import { Modal } from "@renderer/components/modal/modal";
import { useTranslation } from "react-i18next";
import "./modals.scss";
import { removeCustomCss } from "@renderer/helpers";
interface DeleteAllThemesModalProps {
visible: boolean;
@ -17,6 +18,12 @@ export const DeleteAllThemesModal = ({
const { t } = useTranslation("settings");
const handleDeleteAllThemes = async () => {
const activeTheme = await window.electron.getActiveCustomTheme();
if (activeTheme) {
removeCustomCss();
}
await window.electron.deleteAllCustomThemes();
onClose();
onThemesDeleted();

View File

@ -2,11 +2,13 @@ import { Button } from "@renderer/components/button/button";
import { Modal } from "@renderer/components/modal/modal";
import { useTranslation } from "react-i18next";
import "./modals.scss";
import { removeCustomCss } from "@renderer/helpers";
interface DeleteThemeModalProps {
visible: boolean;
onClose: () => void;
themeId: string;
isActive: boolean;
onThemeDeleted: () => void;
themeName: string;
}
@ -15,12 +17,17 @@ export const DeleteThemeModal = ({
visible,
onClose,
themeId,
isActive,
onThemeDeleted,
themeName,
}: DeleteThemeModalProps) => {
const { t } = useTranslation("settings");
const handleDeleteTheme = async () => {
if (isActive) {
removeCustomCss();
}
await window.electron.deleteCustomTheme(themeId);
onThemeDeleted();
};