fix chat agent delete

This commit is contained in:
an-lee
2024-08-15 17:49:11 +08:00
parent 75faa44618
commit 94639b3076

View File

@@ -28,7 +28,6 @@ import {
SelectValue,
Slider,
Textarea,
toast,
} from "@renderer/components/ui";
import { t } from "i18next";
import { LANGUAGES } from "@/constants";
@@ -50,7 +49,7 @@ export const ChatAgentForm = (props: {
onDestroy: () => void;
}) => {
const { agent, onSave, onDestroy } = props;
const { learningLanguage, webApi, EnjoyApp } = useContext(
const { learningLanguage, webApi } = useContext(
AppSettingsProviderContext
);
const { openai } = useContext(AISettingsProviderContext);
@@ -127,15 +126,6 @@ export const ChatAgentForm = (props: {
setGptProviders({ ...providers });
};
const destroyChatAgent = async () => {
EnjoyApp.chatAgents
.destroy(agent.id)
.then(() => onDestroy())
.catch((e) => {
toast.error(t(e.message));
});
};
const refreshTtsProviders = async () => {
let providers = TTS_PROVIDERS;
@@ -455,7 +445,7 @@ export const ChatAgentForm = (props: {
<AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
<AlertDialogAction
className="bg-destructive hover:bg-destructive-hover"
onClick={destroyChatAgent}
onClick={onDestroy}
>
{t("delete")}
</AlertDialogAction>