Skip to content

Commit 864359f

Browse files
committed
fix bug with allowMinimumUploadDuration throwing error
1 parent 18f42c5 commit 864359f

11 files changed

Lines changed: 66 additions & 49 deletions

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3+
## 4.27.1
4+
5+
- Fix issue with `allowMinimumUploadDuration` set to `false` throwing error.
6+
37
## 4.27.0
48

5-
- add `allowMinimumUploadDuration` set to `false` to prevent a minimum upload time of 750ms.
9+
- Add `allowMinimumUploadDuration` set to `false` to prevent a minimum upload time of 750ms.
610

711
## 4.26.2
812

dist/filepond.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.27.0
2+
* FilePond 4.27.1
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/

dist/filepond.esm.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.27.0
2+
* FilePond 4.27.1
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -3213,7 +3213,7 @@ const createPerceivedPerformanceUpdater = (
32133213
timeout = setTimeout(tick, delay);
32143214
};
32153215

3216-
tick();
3216+
if (duration > 0) tick();
32173217

32183218
return {
32193219
clear: () => {
@@ -3314,7 +3314,10 @@ const createFileProcessor = (processFn, options) => {
33143314
// we are really done
33153315
// if perceived progress is 1 ( wait for perceived progress to complete )
33163316
// or if server does not support progress ( null )
3317-
if (state.perceivedProgress === 1) {
3317+
if (
3318+
!allowMinimumUploadDuration ||
3319+
(allowMinimumUploadDuration && state.perceivedProgress === 1)
3320+
) {
33183321
completeFn();
33193322
}
33203323
},
@@ -3390,9 +3393,13 @@ const createFileProcessor = (processFn, options) => {
33903393
state.response = null;
33913394
};
33923395

3393-
const getProgress = () =>
3394-
state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
3395-
const getDuration = () => Math.min(state.duration, state.perceivedDuration);
3396+
const getProgress = allowMinimumUploadDuration
3397+
? () => (state.progress ? Math.min(state.progress, state.perceivedProgress) : null)
3398+
: () => state.progress || null;
3399+
3400+
const getDuration = allowMinimumUploadDuration
3401+
? () => Math.min(state.duration, state.perceivedDuration)
3402+
: () => state.duration;
33963403

33973404
const api = {
33983405
...on(),

dist/filepond.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.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.27.0
2+
* FilePond 4.27.1
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -5371,7 +5371,7 @@
53715371
timeout = setTimeout(tick, delay);
53725372
};
53735373

5374-
tick();
5374+
if (duration > 0) tick();
53755375

53765376
return {
53775377
clear: function clear() {
@@ -5471,7 +5471,10 @@
54715471
// we are really done
54725472
// if perceived progress is 1 ( wait for perceived progress to complete )
54735473
// or if server does not support progress ( null )
5474-
if (state.perceivedProgress === 1) {
5474+
if (
5475+
!allowMinimumUploadDuration ||
5476+
(allowMinimumUploadDuration && state.perceivedProgress === 1)
5477+
) {
54755478
completeFn();
54765479
}
54775480
},
@@ -5547,12 +5550,21 @@
55475550
state.response = null;
55485551
};
55495552

5550-
var getProgress = function getProgress() {
5551-
return state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
5552-
};
5553-
var getDuration = function getDuration() {
5554-
return Math.min(state.duration, state.perceivedDuration);
5555-
};
5553+
var getProgress = allowMinimumUploadDuration
5554+
? function() {
5555+
return state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
5556+
}
5557+
: function() {
5558+
return state.progress || null;
5559+
};
5560+
5561+
var getDuration = allowMinimumUploadDuration
5562+
? function() {
5563+
return Math.min(state.duration, state.perceivedDuration);
5564+
}
5565+
: function() {
5566+
return state.duration;
5567+
};
55565568

55575569
var api = Object.assign({}, on(), {
55585570
process: process, // start processing file
@@ -7375,7 +7387,6 @@
73757387
var write = function write(_ref2) {
73767388
var root = _ref2.root,
73777389
props = _ref2.props;
7378-
73797390
if (props.opacity === 0) {
73807391
return;
73817392
}

dist/filepond.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/filepond.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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "filepond",
3-
"version": "4.27.0",
3+
"version": "4.27.1",
44
"description": "FilePond, Where files go to stretch their bits.",
55
"license": "MIT",
66
"author": {

src/js/app/utils/createFileProcessor.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ export const createFileProcessor = (processFn, options) => {
9595
// we are really done
9696
// if perceived progress is 1 ( wait for perceived progress to complete )
9797
// or if server does not support progress ( null )
98-
if (state.perceivedProgress === 1) {
98+
if (
99+
!allowMinimumUploadDuration ||
100+
(allowMinimumUploadDuration && state.perceivedProgress === 1)
101+
) {
99102
completeFn();
100103
}
101104
},
@@ -171,9 +174,13 @@ export const createFileProcessor = (processFn, options) => {
171174
state.response = null;
172175
};
173176

174-
const getProgress = () =>
175-
state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
176-
const getDuration = () => Math.min(state.duration, state.perceivedDuration);
177+
const getProgress = allowMinimumUploadDuration
178+
? () => (state.progress ? Math.min(state.progress, state.perceivedProgress) : null)
179+
: () => state.progress || null;
180+
181+
const getDuration = allowMinimumUploadDuration
182+
? () => Math.min(state.duration, state.perceivedDuration)
183+
: () => state.duration;
177184

178185
const api = {
179186
...on(),

src/js/app/utils/createPerceivedPerformanceUpdater.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const createPerceivedPerformanceUpdater = (
1111
const start = Date.now();
1212

1313
const tick = () => {
14-
1514
let runtime = Date.now() - start;
1615
let delay = getRandomNumber(tickMin, tickMax);
1716

@@ -30,11 +29,11 @@ export const createPerceivedPerformanceUpdater = (
3029
timeout = setTimeout(tick, delay);
3130
};
3231

33-
tick();
32+
if (duration > 0) tick();
3433

3534
return {
3635
clear: () => {
3736
clearTimeout(timeout);
38-
}
37+
},
3938
};
4039
};

0 commit comments

Comments
 (0)