Skip to content

Commit 18f42c5

Browse files
committed
add allowMinimumUploadDuration option to disable perceived performance helper
1 parent a3590a7 commit 18f42c5

File tree

11 files changed

+87
-65
lines changed

11 files changed

+87
-65
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.27.0
4+
5+
- add `allowMinimumUploadDuration` set to `false` to prevent a minimum upload time of 750ms.
6+
37
## 4.26.2
48

59
- `setMetadata` internal `silent` bool now does fire internal `DID_UPDATE_ITEM_METADATA` but doesn't trigger upload or file prepare logic. This fixes an issue with the new image editor and file poster plugins.

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.26.2
2+
* FilePond 4.27.0
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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.26.2
2+
* FilePond 4.27.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -1851,6 +1851,7 @@ const defaultOptions = {
18511851
// Upload related
18521852
instantUpload: [true, Type.BOOLEAN], // Should upload files immediately on drop
18531853
maxParallelUploads: [2, Type.INT], // Maximum files to upload in parallel
1854+
allowMinimumUploadDuration: [true, Type.BOOLEAN], // if true uploads take at least 750 ms, this ensures the user sees the upload progress giving trust the upload actually happened
18541855

18551856
// Chunks
18561857
chunkUploads: [false, Type.BOOLEAN], // Enable chunked uploads
@@ -3221,7 +3222,7 @@ const createPerceivedPerformanceUpdater = (
32213222
};
32223223
};
32233224

3224-
const createFileProcessor = processFn => {
3225+
const createFileProcessor = (processFn, options) => {
32253226
const state = {
32263227
complete: false,
32273228
perceivedProgress: 0,
@@ -3234,6 +3235,8 @@ const createFileProcessor = processFn => {
32343235
response: null,
32353236
};
32363237

3238+
const { allowMinimumUploadDuration } = options;
3239+
32373240
const process = (file, metadata) => {
32383241
const progressFn = () => {
32393242
// we've not yet started the real download, stop here
@@ -3273,7 +3276,7 @@ const createFileProcessor = processFn => {
32733276
},
32743277
// random delay as in a list of files you start noticing
32753278
// files uploading at the exact same speed
3276-
getRandomNumber(750, 1500)
3279+
allowMinimumUploadDuration ? getRandomNumber(750, 1500) : 0
32773280
);
32783281

32793282
// remember request so we can abort it later
@@ -4743,7 +4746,10 @@ const actions = (dispatch, query, state) => ({
47434746
chunkForce: options.chunkForce,
47444747
chunkSize: options.chunkSize,
47454748
chunkRetryDelays: options.chunkRetryDelays,
4746-
})
4749+
}),
4750+
{
4751+
allowMinimumUploadDuration: query('GET_ALLOW_MINIMUM_UPLOAD_DURATION'),
4752+
}
47474753
),
47484754
// called when the file is about to be processed so it can be piped through the transform filters
47494755
(file, success, error) => {

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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.26.2
2+
* FilePond 4.27.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -3777,6 +3777,7 @@
37773777
// Upload related
37783778
instantUpload: [true, Type.BOOLEAN], // Should upload files immediately on drop
37793779
maxParallelUploads: [2, Type.INT], // Maximum files to upload in parallel
3780+
allowMinimumUploadDuration: [true, Type.BOOLEAN], // if true uploads take at least 750 ms, this ensures the user sees the upload progress giving trust the upload actually happened
37803781

37813782
// Chunks
37823783
chunkUploads: [false, Type.BOOLEAN], // Enable chunked uploads
@@ -3798,6 +3799,7 @@
37983799
'Drag & Drop your files or <span class="filepond--label-action">Browse</span>',
37993800
Type.STRING,
38003801
],
3802+
38013803
labelInvalidField: ['Field contains invalid files', Type.STRING],
38023804
labelFileWaitingForSize: ['Waiting for size', Type.STRING],
38033805
labelFileSizeNotAvailable: ['Size not available', Type.STRING],
@@ -5378,7 +5380,7 @@
53785380
};
53795381
};
53805382

5381-
var createFileProcessor = function createFileProcessor(processFn) {
5383+
var createFileProcessor = function createFileProcessor(processFn, options) {
53825384
var state = {
53835385
complete: false,
53845386
perceivedProgress: 0,
@@ -5390,6 +5392,7 @@
53905392
request: null,
53915393
response: null,
53925394
};
5395+
var allowMinimumUploadDuration = options.allowMinimumUploadDuration;
53935396

53945397
var process = function process(file, metadata) {
53955398
var progressFn = function progressFn() {
@@ -5430,7 +5433,7 @@
54305433
},
54315434
// random delay as in a list of files you start noticing
54325435
// files uploading at the exact same speed
5433-
getRandomNumber(750, 1500)
5436+
allowMinimumUploadDuration ? getRandomNumber(750, 1500) : 0
54345437
);
54355438

54365439
// remember request so we can abort it later
@@ -7115,7 +7118,11 @@
71157118
chunkSize: options.chunkSize,
71167119
chunkRetryDelays: options.chunkRetryDelays,
71177120
}
7118-
)
7121+
),
7122+
7123+
{
7124+
allowMinimumUploadDuration: query('GET_ALLOW_MINIMUM_UPLOAD_DURATION'),
7125+
}
71197126
),
71207127

71217128
// called when the file is about to be processed so it can be piped through the transform filters

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.26.2",
3+
"version": "4.27.0",
44
"description": "FilePond, Where files go to stretch their bits.",
55
"license": "MIT",
66
"author": {

src/js/app/actions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,10 @@ export const actions = (dispatch, query, state) => ({
822822
chunkForce: options.chunkForce,
823823
chunkSize: options.chunkSize,
824824
chunkRetryDelays: options.chunkRetryDelays,
825-
})
825+
}),
826+
{
827+
allowMinimumUploadDuration: query('GET_ALLOW_MINIMUM_UPLOAD_DURATION'),
828+
}
826829
),
827830
// called when the file is about to be processed so it can be piped through the transform filters
828831
(file, success, error) => {

src/js/app/options.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ export const setOptions = opts => {
1818
if (!defaultOptions[key]) {
1919
return;
2020
}
21-
defaultOptions[key][0] = getValueByType(value, defaultOptions[key][0], defaultOptions[key][1]);
21+
defaultOptions[key][0] = getValueByType(
22+
value,
23+
defaultOptions[key][0],
24+
defaultOptions[key][1]
25+
);
2226
});
2327
};
2428

2529
// default options on app
2630
export const defaultOptions = {
27-
2831
// the id to add to the root element
2932
id: [null, Type.STRING],
3033

@@ -72,7 +75,7 @@ export const defaultOptions = {
7275
itemInsertLocationFreedom: [true, Type.BOOLEAN], // Set to false to always add items to begin or end of list
7376
itemInsertLocation: ['before', Type.STRING], // Default index in list to add items that have been dropped at the top of the list
7477
itemInsertInterval: [75, Type.INT],
75-
78+
7679
// Drag 'n Drop related
7780
dropOnPage: [false, Type.BOOLEAN], // Allow dropping of files anywhere on page (prevents browser from opening file if dropped outside of Up)
7881
dropOnElement: [true, Type.BOOLEAN], // Drop needs to happen on element (set to false to also load drops outside of Up)
@@ -82,7 +85,8 @@ export const defaultOptions = {
8285
// Upload related
8386
instantUpload: [true, Type.BOOLEAN], // Should upload files immediately on drop
8487
maxParallelUploads: [2, Type.INT], // Maximum files to upload in parallel
85-
88+
allowMinimumUploadDuration: [true, Type.BOOLEAN], // if true uploads take at least 750 ms, this ensures the user sees the upload progress giving trust the upload actually happened
89+
8690
// Chunks
8791
chunkUploads: [false, Type.BOOLEAN], // Enable chunked uploads
8892
chunkForce: [false, Type.BOOLEAN], // Force use of chunk uploads even for files smaller than chunk size
@@ -93,13 +97,16 @@ export const defaultOptions = {
9397
server: [null, Type.SERVER_API],
9498

9599
// File size calculations, can set to 1024, this is only used for display, properties use file size base 1000
96-
fileSizeBase: [1000, Type.INT],
100+
fileSizeBase: [1000, Type.INT],
97101

98102
// Labels and status messages
99103
labelDecimalSeparator: [getDecimalSeparator(), Type.STRING], // Default is locale separator
100104
labelThousandsSeparator: [getThousandsSeparator(), Type.STRING], // Default is locale separator
101105

102-
labelIdle: ['Drag & Drop your files or <span class="filepond--label-action">Browse</span>', Type.STRING],
106+
labelIdle: [
107+
'Drag & Drop your files or <span class="filepond--label-action">Browse</span>',
108+
Type.STRING,
109+
],
103110
labelInvalidField: ['Field contains invalid files', Type.STRING],
104111
labelFileWaitingForSize: ['Waiting for size', Type.STRING],
105112
labelFileSizeNotAvailable: ['Size not available', Type.STRING],
@@ -115,11 +122,11 @@ export const defaultOptions = {
115122
labelFileProcessingAborted: ['Upload cancelled', Type.STRING],
116123
labelFileProcessingError: ['Error during upload', Type.STRING],
117124
labelFileProcessingRevertError: ['Error during revert', Type.STRING],
118-
125+
119126
labelTapToCancel: ['tap to cancel', Type.STRING],
120127
labelTapToRetry: ['tap to retry', Type.STRING],
121128
labelTapToUndo: ['tap to undo', Type.STRING],
122-
129+
123130
labelButtonRemoveItem: ['Remove', Type.STRING],
124131
labelButtonAbortItemLoad: ['Abort', Type.STRING],
125132
labelButtonRetryItemLoad: ['Retry', Type.STRING],
@@ -131,23 +138,23 @@ export const defaultOptions = {
131138
// make sure width and height plus viewpox are even numbers so icons are nicely centered
132139
iconRemove: [
133140
'<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M11.586 13l-2.293 2.293a1 1 0 0 0 1.414 1.414L13 14.414l2.293 2.293a1 1 0 0 0 1.414-1.414L14.414 13l2.293-2.293a1 1 0 0 0-1.414-1.414L13 11.586l-2.293-2.293a1 1 0 0 0-1.414 1.414L11.586 13z" fill="currentColor" fill-rule="nonzero"/></svg>',
134-
Type.STRING
141+
Type.STRING,
135142
],
136143
iconProcess: [
137144
'<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M14 10.414v3.585a1 1 0 0 1-2 0v-3.585l-1.293 1.293a1 1 0 0 1-1.414-1.415l3-3a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1-1.414 1.415L14 10.414zM9 18a1 1 0 0 1 0-2h8a1 1 0 0 1 0 2H9z" fill="currentColor" fill-rule="evenodd"/></svg>',
138-
Type.STRING
145+
Type.STRING,
139146
],
140147
iconRetry: [
141148
'<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M10.81 9.185l-.038.02A4.997 4.997 0 0 0 8 13.683a5 5 0 0 0 5 5 5 5 0 0 0 5-5 1 1 0 0 1 2 0A7 7 0 1 1 9.722 7.496l-.842-.21a.999.999 0 1 1 .484-1.94l3.23.806c.535.133.86.675.73 1.21l-.804 3.233a.997.997 0 0 1-1.21.73.997.997 0 0 1-.73-1.21l.23-.928v-.002z" fill="currentColor" fill-rule="nonzero"/></svg>',
142-
Type.STRING
149+
Type.STRING,
143150
],
144151
iconUndo: [
145152
'<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M9.185 10.81l.02-.038A4.997 4.997 0 0 1 13.683 8a5 5 0 0 1 5 5 5 5 0 0 1-5 5 1 1 0 0 0 0 2A7 7 0 1 0 7.496 9.722l-.21-.842a.999.999 0 1 0-1.94.484l.806 3.23c.133.535.675.86 1.21.73l3.233-.803a.997.997 0 0 0 .73-1.21.997.997 0 0 0-1.21-.73l-.928.23-.002-.001z" fill="currentColor" fill-rule="nonzero"/></svg>',
146-
Type.STRING
153+
Type.STRING,
147154
],
148155
iconDone: [
149156
'<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M18.293 9.293a1 1 0 0 1 1.414 1.414l-7.002 7a1 1 0 0 1-1.414 0l-3.998-4a1 1 0 1 1 1.414-1.414L12 15.586l6.294-6.293z" fill="currentColor" fill-rule="nonzero"/></svg>',
150-
Type.STRING
157+
Type.STRING,
151158
],
152159

153160
// event handlers
@@ -177,8 +184,8 @@ export const defaultOptions = {
177184
beforePrepareFile: [null, Type.FUNCTION],
178185

179186
// styles
180-
stylePanelLayout: [null, Type.STRING], // null 'integrated', 'compact', 'circle'
181-
stylePanelAspectRatio: [null, Type.STRING], // null or '3:2' or 1
187+
stylePanelLayout: [null, Type.STRING], // null 'integrated', 'compact', 'circle'
188+
stylePanelAspectRatio: [null, Type.STRING], // null or '3:2' or 1
182189
styleItemPanelAspectRatio: [null, Type.STRING],
183190
styleButtonRemoveItemPosition: ['left', Type.STRING],
184191
styleButtonProcessItemPosition: ['right', Type.STRING],
@@ -190,5 +197,5 @@ export const defaultOptions = {
190197
files: [[], Type.ARRAY],
191198

192199
// show support by displaying credits
193-
credits: [['https://pqina.nl/', 'Powered by PQINA'], Type.ARRAY]
200+
credits: [['https://pqina.nl/', 'Powered by PQINA'], Type.ARRAY],
194201
};

0 commit comments

Comments
 (0)