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 {
|
} else {
|
||||||
// Contains more than one image and/or other files
|
// Contains more than one image and/or other files
|
||||||
|
|
||||||
// We are currently losing a link to a file if the link is too long,
|
// We are currently losing a link to a file if the link is too long
|
||||||
// but we can't do much about it
|
// We could truncate the filename ?
|
||||||
const maxFieldValueLength = 1024;
|
const maxFieldValueLength = 1024;
|
||||||
const files = attachments
|
const files = attachments
|
||||||
.map((file) => `[${file.name}](${file.url})`)
|
.map((file) => `[${file.name}](${file.url})`)
|
||||||
|
@ -25,8 +25,7 @@ export const handleAttachments = (
|
||||||
files.forEach((file, idx) => {
|
files.forEach((file, idx) => {
|
||||||
const fieldValue = currentField.length > 0 ? `${currentField}, ${file}` : file;
|
const fieldValue = currentField.length > 0 ? `${currentField}, ${file}` : file;
|
||||||
|
|
||||||
// TODO: There is a bug when there is ONE field, it crashes
|
if (fieldValue.length > maxFieldValueLength) {
|
||||||
if (fieldValue.length > maxFieldValueLength || idx === files.length - 1) {
|
|
||||||
multiple = multiple === 0 && idx !== files.length - 1 ? 1 : multiple + 1;
|
multiple = multiple === 0 && idx !== files.length - 1 ? 1 : multiple + 1;
|
||||||
fields.push({
|
fields.push({
|
||||||
name:
|
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);
|
embed.addFields(fields);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue