do not use meta
This commit is contained in:
@@ -173,20 +173,6 @@ export async function buildFilesForUpload(attachments = [], { onlyNew = false }
|
|||||||
filePayload.thumbavif = thumbBase64;
|
filePayload.thumbavif = thumbBase64;
|
||||||
}
|
}
|
||||||
|
|
||||||
const meta = {};
|
|
||||||
if (attachment.thumbnail) {
|
|
||||||
meta.thumbnail = attachment.thumbnail;
|
|
||||||
}
|
|
||||||
if (attachment.text) {
|
|
||||||
meta.text = attachment.text;
|
|
||||||
}
|
|
||||||
if (attachment.parentPdfId) {
|
|
||||||
meta.parentPdfId = String(attachment.parentPdfId);
|
|
||||||
}
|
|
||||||
if (Object.keys(meta).length > 0) {
|
|
||||||
filePayload.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
files.push(filePayload);
|
files.push(filePayload);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Fehler beim Konvertieren von Datei zu Base64:', err);
|
console.error('Fehler beim Konvertieren von Datei zu Base64:', err);
|
||||||
@@ -283,24 +269,7 @@ export async function restoreAttachmentsFromApi(apiFiles = [], existingAttachmen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Check meta.thumbnail if thumbavif wasn't available
|
// 2. Fallback to existing matching attachment thumbnail
|
||||||
if (!thumbnail && apiFile.meta?.thumbnail) {
|
|
||||||
try {
|
|
||||||
const metaThumb = apiFile.meta.thumbnail;
|
|
||||||
if (typeof metaThumb === 'string') {
|
|
||||||
if (metaThumb.startsWith('data:') || metaThumb.startsWith('blob:')) {
|
|
||||||
thumbnail = metaThumb;
|
|
||||||
} else {
|
|
||||||
const thumbBlob = base64ToBlob(metaThumb, 'image/avif');
|
|
||||||
thumbnail = URL.createObjectURL(thumbBlob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (metaThumbErr) {
|
|
||||||
console.error('Fehler beim Dekodieren von meta.thumbnail:', metaThumbErr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Fallback to existing matching attachment thumbnail
|
|
||||||
const matchingExisting =
|
const matchingExisting =
|
||||||
existingMap.get(String(apiFile.id)) ||
|
existingMap.get(String(apiFile.id)) ||
|
||||||
existingMap.get(String(apiFile.fileId)) ||
|
existingMap.get(String(apiFile.fileId)) ||
|
||||||
@@ -317,8 +286,8 @@ export async function restoreAttachmentsFromApi(apiFiles = [], existingAttachmen
|
|||||||
? matchingExisting.file
|
? matchingExisting.file
|
||||||
: new File([''], placeholderName, { type: placeholderType });
|
: new File([''], placeholderName, { type: placeholderType });
|
||||||
|
|
||||||
const text = apiFile.meta?.text || matchingExisting?.text || null;
|
const text = matchingExisting?.text || null;
|
||||||
const parentPdfId = apiFile.meta?.parentPdfId || matchingExisting?.parentPdfId || null;
|
const parentPdfId = matchingExisting?.parentPdfId || null;
|
||||||
|
|
||||||
attachments.push({
|
attachments.push({
|
||||||
id: apiFile.id,
|
id: apiFile.id,
|
||||||
@@ -370,19 +339,10 @@ export function collectFilesForUpload(attachments = [], { onlyNew = false } = {}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const meta = {};
|
|
||||||
if (attachment.parentPdfId) {
|
|
||||||
meta.parentPdfId = String(attachment.parentPdfId);
|
|
||||||
}
|
|
||||||
if (attachment.text) {
|
|
||||||
meta.text = String(attachment.text);
|
|
||||||
}
|
|
||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
file: fileToUpload,
|
file: fileToUpload,
|
||||||
name: attachment.name || fileToUpload.name,
|
name: attachment.name || fileToUpload.name,
|
||||||
mimetype: attachment.type || fileToUpload.type,
|
mimetype: attachment.type || fileToUpload.type,
|
||||||
meta: Object.keys(meta).length > 0 ? meta : undefined,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
@@ -426,14 +386,6 @@ export async function buildManifestBody(
|
|||||||
const isUpdate = !requireAtLeastOne;
|
const isUpdate = !requireAtLeastOne;
|
||||||
const filesToUpload = collectFilesForUpload(form.attachments, { onlyNew: isUpdate });
|
const filesToUpload = collectFilesForUpload(form.attachments, { onlyNew: isUpdate });
|
||||||
if (filesToUpload.length > 0) {
|
if (filesToUpload.length > 0) {
|
||||||
const filesMeta = filesToUpload
|
|
||||||
.filter((f) => f.meta)
|
|
||||||
.map((f) => ({ name: f.name, meta: f.meta }));
|
|
||||||
|
|
||||||
if (filesMeta.length > 0) {
|
|
||||||
body.filesMeta = filesMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('data', JSON.stringify(body));
|
formData.append('data', JSON.stringify(body));
|
||||||
for (const item of filesToUpload) {
|
for (const item of filesToUpload) {
|
||||||
|
|||||||
@@ -569,10 +569,13 @@ class LieferungNeuPage extends PureComponent {
|
|||||||
|
|
||||||
handleAttachmentClick(attachment) {
|
handleAttachmentClick(attachment) {
|
||||||
if (!attachment) return;
|
if (!attachment) return;
|
||||||
|
const isPdf =
|
||||||
|
attachment.type === 'application/pdf' ||
|
||||||
|
attachment.name?.toLowerCase().endsWith('.pdf');
|
||||||
const isText =
|
const isText =
|
||||||
attachment.type?.startsWith('text/') ||
|
!isPdf &&
|
||||||
attachment.name?.toLowerCase().endsWith('.txt') ||
|
(attachment.type?.startsWith('text/') ||
|
||||||
Boolean(attachment.text);
|
attachment.name?.toLowerCase().endsWith('.txt'));
|
||||||
|
|
||||||
if (isText) {
|
if (isText) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
Reference in New Issue
Block a user