Skip to content

Commit d3ac591

Browse files
committed
only request active items when calculating total size
1 parent f2346a5 commit d3ac591

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

dist/filepond-plugin-file-validate-size.esm.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* FilePondPluginFileValidateSize 1.0.4
2+
* FilePondPluginFileValidateSize 2.0.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT
44
* Please visit https://pqina.nl/filepond for details.
55
*/
@@ -51,9 +51,12 @@ var plugin$1 = ({ addFilter, utils }) => {
5151
const totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE');
5252
if (totalSizeMax !== null) {
5353
// get the current total file size
54-
const currentTotalSize = query('GET_ITEMS').reduce((total, item) => {
55-
return total + item.fileSize;
56-
}, 0);
54+
const currentTotalSize = query('GET_ACTIVE_ITEMS').reduce(
55+
(total, item) => {
56+
return total + item.fileSize;
57+
},
58+
0
59+
);
5760

5861
// get the size of the new file
5962
if (currentTotalSize > totalSizeMax) {
@@ -100,8 +103,10 @@ var plugin$1 = ({ addFilter, utils }) => {
100103
};
101104
};
102105

103-
if (typeof navigator !== 'undefined' && document) {
104-
// plugin has loaded
106+
const isBrowser =
107+
typeof window !== 'undefined' && typeof window.document !== 'undefined';
108+
109+
if (isBrowser && document) {
105110
document.dispatchEvent(
106111
new CustomEvent('FilePond:pluginloaded', { detail: plugin$1 })
107112
);

dist/filepond-plugin-file-validate-size.esm.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/filepond-plugin-file-validate-size.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* FilePondPluginFileValidateSize 1.0.4
2+
* FilePondPluginFileValidateSize 2.0.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT
44
* Please visit https://pqina.nl/filepond for details.
55
*/
@@ -67,7 +67,7 @@
6767
var totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE');
6868
if (totalSizeMax !== null) {
6969
// get the current total file size
70-
var currentTotalSize = query('GET_ITEMS').reduce(function(
70+
var currentTotalSize = query('GET_ACTIVE_ITEMS').reduce(function(
7171
total,
7272
item
7373
) {
@@ -120,8 +120,10 @@
120120
};
121121
};
122122

123-
if (typeof navigator !== 'undefined' && document) {
124-
// plugin has loaded
123+
var isBrowser =
124+
typeof window !== 'undefined' && typeof window.document !== 'undefined';
125+
126+
if (isBrowser && document) {
125127
document.dispatchEvent(
126128
new CustomEvent('FilePond:pluginloaded', { detail: plugin$1 })
127129
);

dist/filepond-plugin-file-validate-size.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"name": "filepond-plugin-file-validate-size",
3-
"version": "1.0.4",
3+
"version": "2.0.0",
44
"description": "File Size Validation Plugin for FilePond",
55
"homepage": "https://pqina.nl/filepond",
66
"repository": "pqina/filepond-plugin-file-validate-size",
77
"main": "dist/filepond-plugin-file-validate-size.js",
88
"browser": "dist/filepond-plugin-file-validate-size.js",
99
"module": "dist/filepond-plugin-file-validate-size.esm.js",
1010
"license": "MIT",
11+
"peerDependencies": {
12+
"filepond": "^3.1.2"
13+
},
1114
"author": {
1215
"name": "PQINA",
1316
"url": "https://pqina.nl"

0 commit comments

Comments
 (0)