This commit is contained in:
parent
c74a04ed41
commit
f47d62faad
1 changed files with 12 additions and 4 deletions
|
@ -12,8 +12,8 @@ export const handleAttachments = (
|
|||
} else {
|
||||
// Contains more than one image and/or other files
|
||||
|
||||
// We are currently losing a link to a file if the link is too long,
|
||||
// but we can't do much about it
|
||||
// We are currently losing a link to a file if the link is too long
|
||||
// We could truncate the filename ?
|
||||
const maxFieldValueLength = 1024;
|
||||
const files = attachments
|
||||
.map((file) => `[${file.name}](${file.url})`)
|
||||
|
@ -25,8 +25,7 @@ export const handleAttachments = (
|
|||
files.forEach((file, idx) => {
|
||||
const fieldValue = currentField.length > 0 ? `${currentField}, ${file}` : file;
|
||||
|
||||
// TODO: There is a bug when there is ONE field, it crashes
|
||||
if (fieldValue.length > maxFieldValueLength || idx === files.length - 1) {
|
||||
if (fieldValue.length > maxFieldValueLength) {
|
||||
multiple = multiple === 0 && idx !== files.length - 1 ? 1 : multiple + 1;
|
||||
fields.push({
|
||||
name:
|
||||
|
@ -41,6 +40,15 @@ export const handleAttachments = (
|
|||
}
|
||||
});
|
||||
|
||||
if (currentField.length > 0) {
|
||||
fields.push({
|
||||
name:
|
||||
loc.get(attachments.size > 1 && multiple ? "e_attachements" : "e_attachement") +
|
||||
(multiple ? ` (${multiple + 1})` : ""),
|
||||
value: currentField,
|
||||
});
|
||||
}
|
||||
|
||||
embed.addFields(fields);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue