mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-21 05:18:51 +01:00
Handle maxMediaAttachments
being undefined during file cutoff
This commit is contained in:
parent
c277cbca8f
commit
f7d783314e
1 changed files with 13 additions and 10 deletions
|
@ -639,16 +639,19 @@ function Compose({
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// Auto-cut-off files to avoid exceeding maxMediaAttachments
|
// Auto-cut-off files to avoid exceeding maxMediaAttachments
|
||||||
const max = maxMediaAttachments - mediaAttachments.length;
|
let allowedFiles = files;
|
||||||
const allowedFiles = files.slice(0, max);
|
if(maxMediaAttachments !== undefined) {
|
||||||
if (allowedFiles.length <= 0) {
|
const max = maxMediaAttachments - mediaAttachments.length;
|
||||||
alert(
|
allowedFiles = allowedFiles.slice(0, max);
|
||||||
plural(maxMediaAttachments, {
|
if(allowedFiles.length <= 0) {
|
||||||
one: 'You can only attach up to 1 file.',
|
alert(
|
||||||
other: 'You can only attach up to # files.',
|
plural(maxMediaAttachments, {
|
||||||
}),
|
one: 'You can only attach up to 1 file.',
|
||||||
);
|
other: 'You can only attach up to # files.',
|
||||||
return;
|
}),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const mediaFiles = allowedFiles.map((file) => ({
|
const mediaFiles = allowedFiles.map((file) => ({
|
||||||
file,
|
file,
|
||||||
|
|
Loading…
Reference in a new issue