import { ChatStore, ChatStoreMessage } from "@/types/chatstore"; import { calculate_token_length } from "@/chatgpt"; import { Tr } from "@/translate"; import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer"; import { Button } from "./ui/button"; import { useContext } from "react"; import { AppChatStoreContext, AppContext } from "../pages/App"; interface Props { chat: ChatStoreMessage; setShowEdit: (se: boolean) => void; } export function EditMessageDetail({ chat, setShowEdit }: Props) { const { chatStore, setChatStore } = useContext(AppChatStoreContext); if (typeof chat.content !== "object") return
error
; return ( Open Edit Message Detail Modify the content of the message.
{chat.content.map((mdt, index) => (
{mdt.type === "text" ? ( ) : (
{ window.open(mdt.image_url?.url, "_blank"); }} /> { if (typeof chat.content === "string") return; const obj = chat.content[index].image_url; if (obj === undefined) return; obj.detail = obj.detail === "high" ? "low" : "high"; chat.token = calculate_token_length(chat.content); setChatStore({ ...chatStore }); }} >
)}
))}
); }