Refactor chat message type switching logic

This commit is contained in:
2024-05-14 09:35:33 +08:00
parent d4da4c3e32
commit c0ec74638a

View File

@@ -44,17 +44,29 @@ export function EditMessage(props: EditMessageProps) {
/>
)}
<div className={"w-full flex justify-center"}>
{chatStore.develop_mode && <button
{chatStore.develop_mode && (
<button
className="w-full m-2 p-1 rounded bg-red-500"
onClick={() => {
const confirm = window.confirm(
"Change message type will clear the content, are you sure?"
);
if (!confirm) return;
if (typeof chat.content === "string") {
chat.content = []
chat.content = [];
} else {
chat.content = ''
chat.content = "";
}
setChatStore({ ...chatStore })
setChatStore({ ...chatStore });
}}
>Switch to {typeof chat.content === 'string' ? "media message" : "string message"}</button>}
>
Switch to{" "}
{typeof chat.content === "string"
? "media message"
: "string message"}
</button>
)}
<button
className={"w-full m-2 p-1 rounded bg-purple-500"}
onClick={() => {