Lade eine uebernommene E-Mail bei Bedarf vollstaendig, damit Anzeige und Export nicht an der Vorschau haengen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
17a3b3a736
commit
7626c56f3d
7 files changed
+740
-19
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { documentToText, fetchFile, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
|
||||
import { documentToText, downloadMailPart, fetchFile, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import { dateCaption, DirectionChoice, DirectionMark, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
@@ -7,11 +7,17 @@ import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
const SCALES = [0.75, 1, 1.25, 1.5, 2];
|
||||
|
||||
function MailAttachments({ files }) {
|
||||
function MailAttachments({ files, onOpen }) {
|
||||
if (!files?.length) return <p className="muted">Keine Anhänge.</p>;
|
||||
return (
|
||||
<ul className="mail-files">
|
||||
{files.map((file) => <li key={file.filename}>{file.filename}</li>)}
|
||||
{files.map((file) => (
|
||||
<li key={`${file.index ?? "name"}-${file.filename}`}>
|
||||
{onOpen && Number.isInteger(file.index) ? (
|
||||
<button type="button" className="quiet" onClick={() => onOpen(file)}>{file.filename}</button>
|
||||
) : file.filename}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
@@ -218,6 +224,15 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [onClose, pages]);
|
||||
|
||||
async function openMailPart(suffix, filename) {
|
||||
setError("");
|
||||
try {
|
||||
await downloadMailPart(element.id, context, suffix, filename);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function openOriginal() {
|
||||
setError("");
|
||||
try {
|
||||
@@ -380,11 +395,17 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
<p><span>Von</span> {mailDetail.message_from || "Ohne Absender"}</p>
|
||||
<p><span>An</span> {mailDetail.message_to || "Ohne Empfänger"}</p>
|
||||
{mailDetail.message_cc ? <p><span>Kopie</span> {mailDetail.message_cc}</p> : null}
|
||||
<MailAttachments files={mailDetail.attachments} />
|
||||
{letter?.text ? <pre className="mail-letter__body">{letter.text}</pre> : (
|
||||
<p className="muted">{error || "Zu dieser Nachricht liegt kein Text vor. Absender und Empfänger bleiben gespeichert."}</p>
|
||||
{letter?.complete ? (
|
||||
<>
|
||||
<MailAttachments files={letter.attachments} onOpen={(file) => openMailPart(`attachments/${file.index}`, file.filename)} />
|
||||
{letter.text ? <pre className="mail-letter__body">{letter.text}</pre> : (
|
||||
<p className="muted">Diese Nachricht hat keinen lesbaren Text. Die vollständige E-Mail bleibt abrufbar.</p>
|
||||
)}
|
||||
<button type="button" onClick={() => openMailPart("original", "nachricht.eml")}>Vollständige E-Mail</button>
|
||||
</>
|
||||
) : (
|
||||
<p className="muted">{error ? "Die vollständige Nachricht konnte nicht geladen werden." : "Die vollständige Nachricht wird geladen …"}</p>
|
||||
)}
|
||||
{letter?.text_truncated ? <p className="muted">Der Text ist gekürzt. Die Nachricht selbst ist größer als die Vorschau.</p> : null}
|
||||
</article>
|
||||
) : null}
|
||||
{element.kind === "note" ? (
|
||||
|
||||
Reference in new issue
Block a user