thread fix
This commit is contained in:
parent
d58fb8841b
commit
a58ba11566
11 changed files with 177 additions and 30 deletions
|
|
@ -39,7 +39,13 @@ function joinAddresses(value) {
|
|||
.join(", ");
|
||||
}
|
||||
|
||||
function messagePreview(message) {
|
||||
return (message?.new_reply_content || message?.snippet || "").trim();
|
||||
}
|
||||
|
||||
function messageBody(email) {
|
||||
const preview = messagePreview(email);
|
||||
if (preview) return { mode: "text", value: preview };
|
||||
const text = (email?.body_text || email?.text_body || email?.plain_text || "").trim();
|
||||
if (text) return { mode: "text", value: text };
|
||||
const html = (email?.body_html || "").trim();
|
||||
|
|
@ -49,6 +55,39 @@ function messageBody(email) {
|
|||
return { mode: "text", value: "This message has no readable content." };
|
||||
}
|
||||
|
||||
function MessageBodyContent({ message }) {
|
||||
const [showQuoted, setShowQuoted] = useState(false);
|
||||
const body = messageBody(message);
|
||||
const quoted = (message?.quoted_content || "").trim();
|
||||
const hasQuoted = Boolean(message?.has_quoted_text && quoted);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`mail-detail-body${body.mode === "html" ? " is-html" : ""}`}>
|
||||
{body.mode === "html" ? (
|
||||
<div className="mail-detail-body-html" dangerouslySetInnerHTML={{ __html: body.value }} />
|
||||
) : (
|
||||
<div className="mail-detail-body-text">{body.value}</div>
|
||||
)}
|
||||
</div>
|
||||
{hasQuoted ? (
|
||||
<button
|
||||
type="button"
|
||||
className="mail-quoted-toggle"
|
||||
onClick={() => setShowQuoted((open) => !open)}
|
||||
aria-expanded={showQuoted}
|
||||
aria-label={showQuoted ? "Hide quoted text" : "Show quoted text"}
|
||||
>
|
||||
<span aria-hidden="true">···</span>
|
||||
</button>
|
||||
) : null}
|
||||
{showQuoted && quoted ? (
|
||||
<pre className="mail-quoted-body">{quoted}</pre>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function detailTime(email) {
|
||||
const value = email?.received_at || email?.sent_at || email?.created_at || email?.updated_at;
|
||||
if (!value) return { absolute: "", relative: "" };
|
||||
|
|
@ -149,7 +188,6 @@ function MessageBlock({
|
|||
onMove,
|
||||
}) {
|
||||
const [headersOpen, setHeadersOpen] = useState(false);
|
||||
const body = messageBody(message);
|
||||
const time = detailTime(message);
|
||||
const sender = senderIdentity(message);
|
||||
const attachments = message?.attachments || [];
|
||||
|
|
@ -160,7 +198,7 @@ function MessageBlock({
|
|||
<SenderAvatar email={message} />
|
||||
<span className="mail-thread-message-collapsed-main">
|
||||
<strong>{sender?.name}</strong>
|
||||
<span>{message.snippet || message.body_text || ""}</span>
|
||||
<span>{messagePreview(message) || message.body_text || ""}</span>
|
||||
</span>
|
||||
<time>{time.absolute}</time>
|
||||
</button>
|
||||
|
|
@ -218,14 +256,8 @@ function MessageBlock({
|
|||
</MessageAction>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`mail-detail-message-content${body?.mode === "html" ? " is-html" : ""}`}>
|
||||
<div className={`mail-detail-body${body?.mode === "html" ? " is-html" : " is-text"}`}>
|
||||
{body?.mode === "html" ? (
|
||||
<div className="mail-detail-body-html" dangerouslySetInnerHTML={{ __html: body.value }} />
|
||||
) : (
|
||||
<div className="mail-detail-body-text">{body?.value}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="mail-detail-message-content">
|
||||
<MessageBodyContent message={message} />
|
||||
{attachments.length > 0 && (
|
||||
<div className="mail-detail-attachments" aria-label="Attachments">
|
||||
{attachments.map((file) => (
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ function buildReplyContext(message, replyAll = false) {
|
|||
const sender = message?.sender || { name: "", address: "" };
|
||||
const subject = (message?.subject || "").trim();
|
||||
const replySubject = /^re:/i.test(subject) ? subject : `Re: ${subject || "(No subject)"}`;
|
||||
const quote = (message?.body_text || message?.snippet || "").trim();
|
||||
const quote = (message?.new_reply_content || message?.body_text || message?.snippet || "").trim();
|
||||
return {
|
||||
replyToMessageId: message.id,
|
||||
replyAll,
|
||||
|
|
@ -781,7 +781,7 @@ export default function MailboxView({
|
|||
const target = threadDetail?.messages?.[threadDetail.messages.length - 1] || detail;
|
||||
onCompose?.({
|
||||
subject: `Fwd: ${target?.subject || ""}`,
|
||||
bodyHtml: `<p><br></p><blockquote>${(target?.body_text || target?.snippet || "").replace(/\n/g, "<br>")}</blockquote>`,
|
||||
bodyHtml: `<p><br></p><blockquote>${(target?.new_reply_content || target?.body_text || target?.snippet || "").replace(/\n/g, "<br>")}</blockquote>`,
|
||||
});
|
||||
}}
|
||||
onExtractActions={() => detail && extractActions(detail)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue