Schließe die Connector-Kapselung ab, damit Paperless, IMAP und weitere Quellen über dieselbe Anbindung laufen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
75a3949f7c
commit
d6b70d8f92
75 files changed
+9477
-414
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, fetchFile, fetchPaperless } from "../api.js";
|
||||
import { api, fetchExternal, fetchFile } from "../api.js";
|
||||
import { moduleFor } from "../sources/registry-core.js";
|
||||
import { contentSourceSymbol, contentSymbol, symbolUrl } from "../content-symbol.mjs";
|
||||
import { bezugCount, counterpartLabel, directionSymbol } from "../list-meta.mjs";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
@@ -307,20 +308,24 @@ const SYMBOL_LABEL = {
|
||||
};
|
||||
|
||||
function elementSymbol(element) {
|
||||
if (element?.external?.source === "imap") return "email";
|
||||
const media = element?.preview?.media;
|
||||
const representation = moduleFor(element?.external?.source)?.representation;
|
||||
if (media === "email" || representation === "email") return "email";
|
||||
return contentSymbol(element || {});
|
||||
}
|
||||
|
||||
export function sourceLabel(element) {
|
||||
const type = SYMBOL_LABEL[elementSymbol(element)] || "Datei";
|
||||
if (element.external?.source === "paperless") return `${type} · Paperless`;
|
||||
if (element.external?.source === "imap") return "E-Mail";
|
||||
const module = moduleFor(element.external?.source);
|
||||
if (module?.representation === "email") return module.addLabel || "E-Mail";
|
||||
if (module) return `${type} · ${module.addLabel || module.title}`;
|
||||
if (element.kind === "external_ref" && type === "Verweis") return "Referenz";
|
||||
return type;
|
||||
}
|
||||
|
||||
export function mailFacts(element) {
|
||||
if (element?.external?.source !== "imap") return "";
|
||||
const module = moduleFor(element?.external?.source);
|
||||
if (element?.preview?.media !== "email" && module?.representation !== "email") return "";
|
||||
const detail = element.external.detail || {};
|
||||
const from = detail.message_from ? `Von: ${detail.message_from}` : "";
|
||||
const to = detail.message_to ? `An: ${detail.message_to}` : "";
|
||||
@@ -872,7 +877,7 @@ function EntryMark({ element, context, assignable = false, dropId = "", hot = fa
|
||||
if (!photo) return undefined;
|
||||
let alive = true;
|
||||
let current = "";
|
||||
const load = element.preview.source === "paperless" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
|
||||
const load = element.kind === "external_ref" ? fetchExternal(element.id, context) : fetchFile(element.id, context);
|
||||
load.then((blob) => {
|
||||
if (!alive || !blob.type.startsWith("image/")) return;
|
||||
current = URL.createObjectURL(blob);
|
||||
@@ -1963,7 +1968,7 @@ export function ContentBoard({
|
||||
|
||||
async function placeReceipt(hostBinding, payload, element) {
|
||||
if (!payload || payload.elementId === hostBinding.element.id) return;
|
||||
const role = element?.external?.source === "imap" ? "email" : "other";
|
||||
const role = moduleFor(element?.external?.source)?.representation === "email" ? "email" : "other";
|
||||
setPending(true);
|
||||
setError("");
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user