diff --git a/app/src/components/home/SideBar.tsx b/app/src/components/home/SideBar.tsx index f82c088..ba582d8 100644 --- a/app/src/components/home/SideBar.tsx +++ b/app/src/components/home/SideBar.tsx @@ -15,13 +15,14 @@ import { useEffectAsync, } from "../../utils.ts"; import { + deleteAllConversations, deleteConversation, toggleConversation, updateConversationList, } from "../../conversation/history.ts"; import { Button } from "../ui/button.tsx"; import { setMenu } from "../../store/menu.ts"; -import { Copy, LogIn, Plus, RotateCw } from "lucide-react"; +import {Copy, Eraser, LogIn, Plus, RotateCw} from "lucide-react"; import ConversationSegment from "./ConversationSegment.tsx"; import { AlertDialog, @@ -31,7 +32,7 @@ import { AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, - AlertDialogTitle, + AlertDialogTitle, AlertDialogTrigger, } from "../ui/alert-dialog.tsx"; import { getSharedLink, @@ -54,6 +55,7 @@ function SideBar() { const history: ConversationInstance[] = useSelector(selectHistory); const refresh = useRef(null); const [shared, setShared] = useState(""); + const [removeAll, setRemoveAll] = useState(false); useEffectAsync(async () => { await updateConversationList(dispatch); }, []); @@ -75,6 +77,47 @@ function SideBar() {
+ + + + + + + {t("conversation.remove-all-title")} + + {t("conversation.remove-all-description")} + + + + + {t("conversation.cancel")} + + { + e.preventDefault(); + e.stopPropagation(); + + if (await deleteAllConversations(dispatch)) + toast({ + title: t("conversation.delete-success"), + description: t("conversation.delete-success-prompt"), + }); + else + toast({ + title: t("conversation.delete-failed"), + description: t("conversation.delete-failed-prompt"), + }); + setOperateConversation({ target: null, type: "" }); + setRemoveAll(false); + }} + > + {t("conversation.delete")} + + + +