forked from XiaoMo/ChatGPT-Next-Web
fix: #930 wont show delete for first message
This commit is contained in:
parent
06d503152b
commit
2390da1165
@ -723,6 +723,11 @@ export function Chat(props: {
|
|||||||
>
|
>
|
||||||
{messages.map((message, i) => {
|
{messages.map((message, i) => {
|
||||||
const isUser = message.role === "user";
|
const isUser = message.role === "user";
|
||||||
|
const showActions =
|
||||||
|
!isUser &&
|
||||||
|
i > 0 &&
|
||||||
|
!(message.preview || message.content.length === 0);
|
||||||
|
const showTyping = message.preview || message.streaming;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -735,47 +740,46 @@ export function Chat(props: {
|
|||||||
<div className={styles["chat-message-avatar"]}>
|
<div className={styles["chat-message-avatar"]}>
|
||||||
<Avatar role={message.role} model={message.model} />
|
<Avatar role={message.role} model={message.model} />
|
||||||
</div>
|
</div>
|
||||||
{(message.preview || message.streaming) && (
|
{showTyping && (
|
||||||
<div className={styles["chat-message-status"]}>
|
<div className={styles["chat-message-status"]}>
|
||||||
{Locale.Chat.Typing}
|
{Locale.Chat.Typing}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className={styles["chat-message-item"]}>
|
<div className={styles["chat-message-item"]}>
|
||||||
{!isUser &&
|
{showActions && (
|
||||||
!(message.preview || message.content.length === 0) && (
|
<div className={styles["chat-message-top-actions"]}>
|
||||||
<div className={styles["chat-message-top-actions"]}>
|
{message.streaming ? (
|
||||||
{message.streaming ? (
|
|
||||||
<div
|
|
||||||
className={styles["chat-message-top-action"]}
|
|
||||||
onClick={() => onUserStop(message.id ?? i)}
|
|
||||||
>
|
|
||||||
{Locale.Chat.Actions.Stop}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div
|
|
||||||
className={styles["chat-message-top-action"]}
|
|
||||||
onClick={() => onDelete(message.id ?? i)}
|
|
||||||
>
|
|
||||||
{Locale.Chat.Actions.Delete}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className={styles["chat-message-top-action"]}
|
|
||||||
onClick={() => onResend(message.id ?? i)}
|
|
||||||
>
|
|
||||||
{Locale.Chat.Actions.Retry}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={styles["chat-message-top-action"]}
|
className={styles["chat-message-top-action"]}
|
||||||
onClick={() => copyToClipboard(message.content)}
|
onClick={() => onUserStop(message.id ?? i)}
|
||||||
>
|
>
|
||||||
{Locale.Chat.Actions.Copy}
|
{Locale.Chat.Actions.Stop}
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={styles["chat-message-top-action"]}
|
||||||
|
onClick={() => onDelete(message.id ?? i)}
|
||||||
|
>
|
||||||
|
{Locale.Chat.Actions.Delete}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={styles["chat-message-top-action"]}
|
||||||
|
onClick={() => onResend(message.id ?? i)}
|
||||||
|
>
|
||||||
|
{Locale.Chat.Actions.Retry}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={styles["chat-message-top-action"]}
|
||||||
|
onClick={() => copyToClipboard(message.content)}
|
||||||
|
>
|
||||||
|
{Locale.Chat.Actions.Copy}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
|
)}
|
||||||
<Markdown
|
<Markdown
|
||||||
content={message.content}
|
content={message.content}
|
||||||
loading={
|
loading={
|
||||||
|
Loading…
Reference in New Issue
Block a user