Korrigiere IMAP-Ordner, MIME-Ansicht und die gemeinsamen Leser, damit große Postfächer, Notizen und verspätete Quellenantworten zuverlässig bleiben.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
34c4084a7c
commit
c29bd29f34
29 files changed
+2562
-410
No files matched your search
@@ -1,9 +1,8 @@
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { SessionContext } from "../session.js";
|
||||
import { documentToText, downloadMailPart, fetchExternal, fetchFile, fetchMailPart, isDirty, markDirty, textToDocument, api } from "../api.js";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
import { NoteEditor } from "../notes.jsx";
|
||||
import { SourceAssignment, noteEditor, representationOf } from "../sources/registry.jsx";
|
||||
import { SourceAssignment, representationOf, stageFor } from "../sources/registry.jsx";
|
||||
import "../sources/builtin-views.jsx";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import { UnitDetail } from "./correspondence.jsx";
|
||||
import { dateCaption, DateField, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, sourceLabel } from "./content.jsx";
|
||||
@@ -132,14 +131,14 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
useEffect(() => {
|
||||
if (!element) return undefined;
|
||||
const kind = representationOf(element);
|
||||
if (kind === "note" || kind === "mail") setPhase("ready");
|
||||
if (stageFor(kind) || kind === "note" || kind === "mail") setPhase("ready");
|
||||
else if (kind === "locked" || kind === "unassigned" || !element.preview?.available) setPhase("missing");
|
||||
setError("");
|
||||
return undefined;
|
||||
}, [element?.id, element?.kind, element?.external?.source, element?.external?.resolution, element?.file?.protection_profile, element?.preview?.available]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || representationOf(element) === "note" || representationOf(element) === "mail" || representationOf(element) === "locked" || representationOf(element) === "unassigned" || !element.preview?.available) return undefined;
|
||||
if (!element || stageFor(representationOf(element)) || representationOf(element) === "locked" || representationOf(element) === "unassigned" || !element.preview?.available) return undefined;
|
||||
let alive = true;
|
||||
let url = "";
|
||||
setPage(1);
|
||||
@@ -206,7 +205,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}, [element?.id, element?.kind, element?.external?.source, element?.external?.resolution, element?.file?.protection_profile, element?.preview?.available, context?.kind, context?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || representationOf(element) !== "mail") return undefined;
|
||||
if (!element || stageFor("mail") || representationOf(element) !== "mail") return undefined;
|
||||
if (shownIndex === null) {
|
||||
setPhase("ready");
|
||||
setPdf(null);
|
||||
@@ -275,7 +274,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}, [element?.id, element?.external?.source, shownIndex, letter, context?.kind, context?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || representationOf(element) !== "mail") return undefined;
|
||||
if (!element || stageFor("mail") || representationOf(element) !== "mail") return undefined;
|
||||
let alive = true;
|
||||
const params = new URLSearchParams();
|
||||
if (context?.kind && context?.id) {
|
||||
@@ -366,52 +365,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}
|
||||
}
|
||||
|
||||
async function saveNote(event) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
try {
|
||||
const updated = await noteEditor.save({
|
||||
api,
|
||||
element,
|
||||
context,
|
||||
document: textToDocument(text),
|
||||
});
|
||||
pendingNote.current = text;
|
||||
editingRef.current = false;
|
||||
setEditingNote(false);
|
||||
markDirty(false);
|
||||
setNotice(updated.notice || "Der gemeinsame Text ist gespeichert.");
|
||||
onReload();
|
||||
} catch (err) {
|
||||
if (err.status === 409) {
|
||||
setError("Der Stand hat sich geändert. Der eingegebene Text bleibt stehen. Bitte neu laden.");
|
||||
return;
|
||||
}
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function beginNote() {
|
||||
pendingNote.current = "";
|
||||
editingRef.current = true;
|
||||
setText(documentToText(element.document));
|
||||
setNoteSession((current) => current + 1);
|
||||
setEditingNote(true);
|
||||
setError("");
|
||||
setNotice("");
|
||||
}
|
||||
|
||||
function cancelNote() {
|
||||
pendingNote.current = "";
|
||||
editingRef.current = false;
|
||||
setText(documentToText(element.document));
|
||||
setEditingNote(false);
|
||||
markDirty(false);
|
||||
setError("");
|
||||
}
|
||||
|
||||
function requestClose() {
|
||||
if (editingRef.current && isDirty() && !window.confirm("Ungespeicherte Eingaben verwerfen?")) return;
|
||||
if (isDirty() && !window.confirm("Ungespeicherte Eingaben verwerfen?")) return;
|
||||
markDirty(false);
|
||||
onClose();
|
||||
}
|
||||
@@ -538,6 +493,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
const communication = binding.communication || {};
|
||||
const shownDirection = communication.direction || null;
|
||||
const kind = representationOf(element);
|
||||
const Stage = stageFor(kind);
|
||||
const isMail = kind === "mail";
|
||||
const locked = kind === "locked";
|
||||
const unassigned = kind === "unassigned";
|
||||
@@ -589,61 +545,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
onDetach={() => {}}
|
||||
onUnfold={() => {}}
|
||||
/>
|
||||
{isMail ? (
|
||||
<article className="mail-letter">
|
||||
<p className="mail-letter__way"><DirectionColumn direction={shownDirection} />{directionWord(shownDirection) ? <span>{directionWord(shownDirection)}</span> : null}</p>
|
||||
<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}
|
||||
{letter?.complete ? (
|
||||
<>
|
||||
<MailAttachments files={letter.attachments} current={shownIndex} onOpen={(file) => {
|
||||
setError("");
|
||||
setShownFor((current) => (
|
||||
current?.elementId === element.id && current.index === file.index ? null : { elementId: element.id, index: file.index }
|
||||
));
|
||||
}} />
|
||||
{shownFile ? <p className="mail-attachment__caption">Anlage: {shownFile.filename}</p> : null}
|
||||
{shownFile && phase === "loading" ? <p className="muted">Die Anlage wird geladen …</p> : null}
|
||||
{media === "image" && blobUrl ? (
|
||||
<img className="reader-image" alt={shownFile?.filename || element.title} src={blobUrl} style={{ width: `${Math.round(scale * 100)}%` }} />
|
||||
) : null}
|
||||
{media === "pdf" && pdf ? <canvas ref={canvasRef} className="reader-canvas" /> : null}
|
||||
{media === "pdf-frame" && blobUrl ? <iframe className="reader-frame" title={shownFile?.filename || element.title} src={blobUrl} /> : null}
|
||||
{media === "other" && blobUrl ? (
|
||||
<div className="reader-pane__state">
|
||||
<p>Diese Anlage lässt sich hier nicht als Seite zeigen.</p>
|
||||
<a href={blobUrl} target="_blank" rel="noreferrer">Anlage öffnen</a>
|
||||
</div>
|
||||
) : null}
|
||||
{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>
|
||||
)}
|
||||
</article>
|
||||
) : null}
|
||||
{element.kind === "note" && noteEditor.available ? (
|
||||
editingNote && binding.rights.edit ? (
|
||||
<form className="reader-note" onSubmit={saveNote}>
|
||||
<NoteEditor key={noteSession} value={text} onChange={(value) => { setText(value); markDirty(true); }} />
|
||||
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung. Gespeichert wird Markdown.</p>
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
<div className="row">
|
||||
<button type="submit">Text speichern</button>
|
||||
<button type="button" className="quiet" onClick={cancelNote}>Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div className="reader-note">
|
||||
{text.trim() ? <MarkdownView text={text} /> : <p className="muted">Die Notiz ist leer.</p>}
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
{binding.rights.edit ? <button type="button" onClick={beginNote}>Bearbeiten</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
|
||||
</div>
|
||||
)
|
||||
{Stage ? (
|
||||
<Stage element={element} context={context} binding={binding} onReload={onReload} shownDirection={shownDirection} />
|
||||
) : null}
|
||||
<form className="stack reader-direction" onSubmit={(event) => event.preventDefault()}>
|
||||
<DirectionChoice
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, fetchBlob } from "../api.js";
|
||||
import { MailBody } from "../mail-view.jsx";
|
||||
import { SourceFrame, moduleFor, registerSourceModule, sourceModules } from "../sources/registry.jsx";
|
||||
|
||||
const SEARCH_LIMITS = {
|
||||
@@ -201,6 +202,9 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
const [previewUrl, setPreviewUrl] = useState("");
|
||||
const [pending, setPending] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const searchRef = useRef(0);
|
||||
const previewRef = useRef(0);
|
||||
const facetRef = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
api("/api/v1/connectors")
|
||||
@@ -217,13 +221,15 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
setFacets({ correspondents: [], document_types: [], tags: [] });
|
||||
return undefined;
|
||||
}
|
||||
const token = facetRef.current + 1;
|
||||
facetRef.current = token;
|
||||
let alive = true;
|
||||
api(`/api/v1/sources/paperless/facets?connector_id=${connectorId}`)
|
||||
.then((data) => {
|
||||
if (alive) setFacets(data);
|
||||
if (alive && token === facetRef.current) setFacets(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (alive) setError(err.message);
|
||||
if (alive && token === facetRef.current) setError(err.message);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
@@ -253,6 +259,12 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
return params;
|
||||
}
|
||||
|
||||
function invalidate() {
|
||||
searchRef.current += 1;
|
||||
previewRef.current += 1;
|
||||
facetRef.current += 1;
|
||||
}
|
||||
|
||||
async function runSearch(event, page = "") {
|
||||
event?.preventDefault();
|
||||
setError("");
|
||||
@@ -260,12 +272,17 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
setError("Wähle zuerst den Paperless-Zugang.");
|
||||
return;
|
||||
}
|
||||
const token = searchRef.current + 1;
|
||||
searchRef.current = token;
|
||||
const asked = connectorId;
|
||||
try {
|
||||
const data = await api(`/api/v1/sources/paperless/documents?${paramsFor(page)}`);
|
||||
if (token !== searchRef.current) return;
|
||||
setItems(data.items || []);
|
||||
setNextPage(data.next_page || data.continuation || null);
|
||||
if (data.connector_id) setConnectorId(data.connector_id);
|
||||
if (!asked && data.connector_id) setConnectorId(data.connector_id);
|
||||
} catch (err) {
|
||||
if (token !== searchRef.current) return;
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
@@ -291,11 +308,15 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
setError("");
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
setPreviewUrl("");
|
||||
const token = previewRef.current + 1;
|
||||
previewRef.current = token;
|
||||
const bound = item.connector_id || connectorId;
|
||||
try {
|
||||
const bound = item.connector_id || connectorId;
|
||||
const blob = await fetchBlob(`/api/v1/sources/paperless/documents/${item.id}/preview?connector_id=${bound}`);
|
||||
if (token !== previewRef.current) return;
|
||||
setPreviewUrl(URL.createObjectURL(blob));
|
||||
} catch (err) {
|
||||
if (token !== previewRef.current) return;
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
@@ -366,7 +387,16 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
{connectors.length > 1 ? (
|
||||
<label>
|
||||
Paperless-Zugang
|
||||
<select value={connectorId} onChange={(event) => { setConnectorId(event.target.value); setItems([]); setNextPage(null); }}>
|
||||
<select value={connectorId} onChange={(event) => {
|
||||
invalidate();
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
setPreviewUrl("");
|
||||
setConnectorId(event.target.value);
|
||||
setFilters(EMPTY_FILTERS);
|
||||
setItems([]);
|
||||
setNextPage(null);
|
||||
setFacets({ correspondents: [], document_types: [], tags: [] });
|
||||
}}>
|
||||
<option value="">Zugang wählen</option>
|
||||
{connectors.map((item) => (
|
||||
<option key={item.id} value={item.id}>{item.name}</option>
|
||||
@@ -567,6 +597,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
const [items, setItems] = useState([]);
|
||||
const [nextBefore, setNextBefore] = useState(null);
|
||||
const [incomplete, setIncomplete] = useState(false);
|
||||
const [contradictory, setContradictory] = useState(false);
|
||||
const [uidValidity, setUidValidity] = useState(null);
|
||||
const [notice, setNotice] = useState("");
|
||||
const [selectedKey, setSelectedKey] = useState("");
|
||||
@@ -587,6 +618,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
if (token !== requestRef.current) return;
|
||||
setUidValidity(data.uidvalidity ?? null);
|
||||
setIncomplete(Boolean(data.incomplete));
|
||||
setContradictory(Boolean(data.contradictory));
|
||||
setNextBefore(data.next_before ?? data.continuation ?? null);
|
||||
if (data.restarted) {
|
||||
setItems(data.items || []);
|
||||
@@ -644,6 +676,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
setItems([]);
|
||||
setNextBefore(null);
|
||||
setIncomplete(false);
|
||||
setContradictory(false);
|
||||
setNotice("");
|
||||
setSelectedKey("");
|
||||
setPreview(null);
|
||||
@@ -805,12 +838,14 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
{accountId && !loading && !mailbox && !error ? <p className="muted">Dieses Konto hat keine lesbaren Fächer.</p> : null}
|
||||
{loading ? <p className="muted">{loading}</p> : null}
|
||||
{!loading && mailbox && !items.length && !error ? (
|
||||
<p className="muted">
|
||||
{incomplete
|
||||
? "In diesem Abschnitt gibt es keine Treffer. Die Suche ist noch nicht zu Ende."
|
||||
: query
|
||||
? "In diesem Fach gibt es dazu keine Nachricht."
|
||||
: "In diesem Fach gibt es keine Nachricht."}
|
||||
<p className={contradictory ? "notice" : "muted"}>
|
||||
{contradictory
|
||||
? "Das Fach meldet Nachrichten, aber es kam keine Liste an. Das Fach gilt deshalb nicht als leer."
|
||||
: incomplete
|
||||
? "In diesem Abschnitt gibt es keine Treffer. Die Suche ist noch nicht zu Ende."
|
||||
: query
|
||||
? "In diesem Fach gibt es dazu keine Nachricht."
|
||||
: "In diesem Fach gibt es keine Nachricht."}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="mail-list">
|
||||
@@ -847,9 +882,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
<MailFiles files={preview?.attachments || selected.attachments || []} />
|
||||
{previewError ? <p className="error">{previewError}</p> : null}
|
||||
{selected && !preview && !previewError ? <p className="muted">Vorschau wird geladen …</p> : null}
|
||||
{preview?.text ? <pre className="mail-letter__body">{preview.text}</pre> : null}
|
||||
{preview?.text_truncated ? <p className="muted">Der Text ist gekürzt, weil die Nachricht sehr groß ist.</p> : null}
|
||||
{preview && !preview.text ? <p className="muted">Diese Nachricht hat keinen lesbaren Text.</p> : null}
|
||||
{preview ? <MailBody html={preview.html} text={preview.text} truncated={preview.text_truncated} notices={preview.notices} /> : null}
|
||||
<ErrorNote error={error} />
|
||||
<button type="button" onClick={() => link(selected)} disabled={!selected.uid || adopting}>{adopting ? "Wird übernommen …" : "Übernehmen"}</button>
|
||||
</>
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, documentToText, downloadFile, fetchExternal, markDirty, textToDocument } from "../api.js";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
import { stageFor } from "../sources/registry.jsx";
|
||||
import "../sources/builtin-views.jsx";
|
||||
import { NoteEditor } from "../notes.jsx";
|
||||
import { moduleFor } from "../sources/registry-core.js";
|
||||
import { Modal } from "./Modal.jsx";
|
||||
|
||||
function RegisteredNote(props) {
|
||||
const Stage = stageFor("note");
|
||||
return Stage ? <Stage {...props} /> : null;
|
||||
}
|
||||
|
||||
export function ErrorNote({ error }) {
|
||||
if (!error) return null;
|
||||
return <p className="error">{error}</p>;
|
||||
@@ -190,25 +196,7 @@ function Binding({ binding, context, canEdit, isOwner, onChange }) {
|
||||
</div>
|
||||
</header>
|
||||
<DateLine dates={dates} />
|
||||
{element.kind === "note" ? (
|
||||
editingNote && binding.rights.edit ? (
|
||||
<form onSubmit={saveNote} className="stack">
|
||||
<NoteEditor value={text} onChange={(value) => { setText(value); markDirty(true); }} />
|
||||
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz.</p>
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
<div className="row">
|
||||
<button type="submit">Text speichern</button>
|
||||
<button type="button" className="quiet" onClick={() => { setText(documentToText(element.document)); setEditingNote(false); markDirty(false); }}>Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div className="stack">
|
||||
{text.trim() ? <MarkdownView text={text} /> : <p className="muted">Die Notiz ist leer.</p>}
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
{binding.rights.edit ? <button type="button" onClick={() => setEditingNote(true)}>Bearbeiten</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
{element.kind === "note" ? <RegisteredNote element={element} context={context} binding={binding} onReload={onChange} /> : null}
|
||||
{element.kind === "file" && element.file ? (
|
||||
element.file.status === "active" ? (
|
||||
<button type="button" onClick={() => downloadFile(element.id, context, element.file.filename)}>
|
||||
|
||||
Reference in new issue
Block a user