Skip to content

Commit

Permalink
fix bug with allowMinimumUploadDuration throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
rikschennink committed Apr 30, 2021
1 parent 18f42c5 commit 864359f
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 49 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 4.27.1

- Fix issue with `allowMinimumUploadDuration` set to `false` throwing error.

## 4.27.0

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

## 4.26.2

Expand Down
2 changes: 1 addition & 1 deletion dist/filepond.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.27.0
* FilePond 4.27.1
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down
19 changes: 13 additions & 6 deletions dist/filepond.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.27.0
* FilePond 4.27.1
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -3213,7 +3213,7 @@ const createPerceivedPerformanceUpdater = (
timeout = setTimeout(tick, delay);
};

tick();
if (duration > 0) tick();

return {
clear: () => {
Expand Down Expand Up @@ -3314,7 +3314,10 @@ const createFileProcessor = (processFn, options) => {
// we are really done
// if perceived progress is 1 ( wait for perceived progress to complete )
// or if server does not support progress ( null )
if (state.perceivedProgress === 1) {
if (
!allowMinimumUploadDuration ||
(allowMinimumUploadDuration && state.perceivedProgress === 1)
) {
completeFn();
}
},
Expand Down Expand Up @@ -3390,9 +3393,13 @@ const createFileProcessor = (processFn, options) => {
state.response = null;
};

const getProgress = () =>
state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
const getDuration = () => Math.min(state.duration, state.perceivedDuration);
const getProgress = allowMinimumUploadDuration
? () => (state.progress ? Math.min(state.progress, state.perceivedProgress) : null)
: () => state.progress || null;

const getDuration = allowMinimumUploadDuration
? () => Math.min(state.duration, state.perceivedDuration)
: () => state.duration;

const api = {
...on(),
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond.esm.min.js

Large diffs are not rendered by default.

31 changes: 21 additions & 10 deletions dist/filepond.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.27.0
* FilePond 4.27.1
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -5371,7 +5371,7 @@
timeout = setTimeout(tick, delay);
};

tick();
if (duration > 0) tick();

return {
clear: function clear() {
Expand Down Expand Up @@ -5471,7 +5471,10 @@
// we are really done
// if perceived progress is 1 ( wait for perceived progress to complete )
// or if server does not support progress ( null )
if (state.perceivedProgress === 1) {
if (
!allowMinimumUploadDuration ||
(allowMinimumUploadDuration && state.perceivedProgress === 1)
) {
completeFn();
}
},
Expand Down Expand Up @@ -5547,12 +5550,21 @@
state.response = null;
};

var getProgress = function getProgress() {
return state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
};
var getDuration = function getDuration() {
return Math.min(state.duration, state.perceivedDuration);
};
var getProgress = allowMinimumUploadDuration
? function() {
return state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
}
: function() {
return state.progress || null;
};

var getDuration = allowMinimumUploadDuration
? function() {
return Math.min(state.duration, state.perceivedDuration);
}
: function() {
return state.duration;
};

var api = Object.assign({}, on(), {
process: process, // start processing file
Expand Down Expand Up @@ -7375,7 +7387,6 @@
var write = function write(_ref2) {
var root = _ref2.root,
props = _ref2.props;

if (props.opacity === 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/filepond.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/filepond.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filepond",
"version": "4.27.0",
"version": "4.27.1",
"description": "FilePond, Where files go to stretch their bits.",
"license": "MIT",
"author": {
Expand Down
15 changes: 11 additions & 4 deletions src/js/app/utils/createFileProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export const createFileProcessor = (processFn, options) => {
// we are really done
// if perceived progress is 1 ( wait for perceived progress to complete )
// or if server does not support progress ( null )
if (state.perceivedProgress === 1) {
if (
!allowMinimumUploadDuration ||
(allowMinimumUploadDuration && state.perceivedProgress === 1)
) {
completeFn();
}
},
Expand Down Expand Up @@ -171,9 +174,13 @@ export const createFileProcessor = (processFn, options) => {
state.response = null;
};

const getProgress = () =>
state.progress ? Math.min(state.progress, state.perceivedProgress) : null;
const getDuration = () => Math.min(state.duration, state.perceivedDuration);
const getProgress = allowMinimumUploadDuration
? () => (state.progress ? Math.min(state.progress, state.perceivedProgress) : null)
: () => state.progress || null;

const getDuration = allowMinimumUploadDuration
? () => Math.min(state.duration, state.perceivedDuration)
: () => state.duration;

const api = {
...on(),
Expand Down
5 changes: 2 additions & 3 deletions src/js/app/utils/createPerceivedPerformanceUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const createPerceivedPerformanceUpdater = (
const start = Date.now();

const tick = () => {

let runtime = Date.now() - start;
let delay = getRandomNumber(tickMin, tickMax);

Expand All @@ -30,11 +29,11 @@ export const createPerceivedPerformanceUpdater = (
timeout = setTimeout(tick, delay);
};

tick();
if (duration > 0) tick();

return {
clear: () => {
clearTimeout(timeout);
}
},
};
};
25 changes: 7 additions & 18 deletions src/js/app/view/progressIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const create = ({ root, props }) => {
const svg = createElement('svg');
root.ref.path = createElement('path', {
'stroke-width': 2,
'stroke-linecap': 'round'
'stroke-linecap': 'round',
});
svg.appendChild(root.ref.path);

Expand All @@ -23,7 +23,6 @@ const create = ({ root, props }) => {
};

const write = ({ root, props }) => {

if (props.opacity === 0) {
return;
}
Expand Down Expand Up @@ -52,23 +51,13 @@ const write = ({ root, props }) => {
}

// get arc path
const coordinates = percentageArc(
size,
size,
size - ringStrokeWidth,
ringFrom,
ringTo
);
const coordinates = percentageArc(size, size, size - ringStrokeWidth, ringFrom, ringTo);

// update progress bar
attr(root.ref.path, 'd', coordinates);

// hide while contains 0 value
attr(
root.ref.path,
'stroke-opacity',
props.spin || props.progress > 0 ? 1 : 0
);
attr(root.ref.path, 'stroke-opacity', props.spin || props.progress > 0 ? 1 : 0);
};

export const progressIndicator = createView({
Expand All @@ -87,8 +76,8 @@ export const progressIndicator = createView({
type: 'spring',
stiffness: 0.95,
damping: 0.65,
mass: 10
}
}
}
mass: 10,
},
},
},
});

0 comments on commit 864359f

Please sign in to comment.