mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-22 13:49:23 +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,8 +639,10 @@ function Compose({
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Auto-cut-off files to avoid exceeding maxMediaAttachments
|
||||
let allowedFiles = files;
|
||||
if(maxMediaAttachments !== undefined) {
|
||||
const max = maxMediaAttachments - mediaAttachments.length;
|
||||
const allowedFiles = files.slice(0, max);
|
||||
allowedFiles = allowedFiles.slice(0, max);
|
||||
if(allowedFiles.length <= 0) {
|
||||
alert(
|
||||
plural(maxMediaAttachments, {
|
||||
|
@ -650,6 +652,7 @@ function Compose({
|
|||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const mediaFiles = allowedFiles.map((file) => ({
|
||||
file,
|
||||
type: file.type,
|
||||
|
|
Loading…
Reference in a new issue