Skip to content

Commit

Permalink
fix issue where background uploads took way too long
Browse files Browse the repository at this point in the history
  • Loading branch information
rikschennink committed Apr 13, 2020
1 parent 8d9f523 commit b2ff1f4
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 85 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog

## 4.13.2

- Fix issue where FilePond running in an inactive tab would be very slow to pick up new files.


## 4.13.1

- Fix issue where HEAD fetch request would try turn response into zero byte file.
Expand Down
2 changes: 1 addition & 1 deletion dist/filepond.css
@@ -1,5 +1,5 @@
/*!
* FilePond 4.13.1
* FilePond 4.13.2
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down
42 changes: 17 additions & 25 deletions dist/filepond.esm.js
@@ -1,5 +1,5 @@
/*!
* FilePond 4.13.1
* FilePond 4.13.2
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -302,11 +302,9 @@ const spring =
let resting = false;

// updates spring state
const interpolate = () => {
const interpolate = (ts, skipToEndState) => {
// in rest, don't animate
if (resting) {
return;
}
if (resting) return;

// need at least a target or position to do springy things
if (!(isNumber(target) && isNumber(position))) {
Expand All @@ -328,7 +326,7 @@ const spring =
velocity *= damping;

// we've arrived if we're near target and our velocity is near zero
if (thereYet(position, target, velocity)) {
if (thereYet(position, target, velocity) || skipToEndState) {
position = target;
velocity = 0;
resting = true;
Expand Down Expand Up @@ -409,30 +407,26 @@ const tween =
let reverse = false;
let target = null;

const interpolate = ts => {
if (resting || target === null) {
return;
}
const interpolate = (ts, skipToEndState) => {
if (resting || target === null) return;

if (start === null) {
start = ts;
}

if (ts - start < delay) {
return;
}
if (ts - start < delay) return;

t = ts - start - delay;

if (t < duration) {
p = t / duration;
api.onupdate((t >= 0 ? easing(reverse ? 1 - p : p) : 0) * target);
} else {
if (t >= duration || skipToEndState) {
t = 1;
p = reverse ? 0 : 1;
api.onupdate(p * target);
api.oncomplete(p * target);
resting = true;
} else {
p = t / duration;
api.onupdate((t >= 0 ? easing(reverse ? 1 - p : p) : 0) * target);
}
};

Expand Down Expand Up @@ -525,8 +519,6 @@ const addGetSet = (keys, obj, props, overwrite = false) => {
});
};

const isDefined = value => value != null;

// add to state,
// add getters and setters to internal and external api (if not set)
// setup animators
Expand All @@ -535,8 +527,7 @@ const animations = ({
mixinConfig,
viewProps,
viewInternalAPI,
viewExternalAPI,
viewState
viewExternalAPI
}) => {
// initial properties
const initialProps = { ...viewProps };
Expand Down Expand Up @@ -583,12 +574,11 @@ const animations = ({
// expose internal write api
return {
write: ts => {
let skipToEndState = document.hidden;
let resting = true;
animations.forEach(animation => {
if (!animation.resting) {
resting = false;
}
animation.interpolate(ts);
if (!animation.resting) resting = false;
animation.interpolate(ts, skipToEndState);
});
return resting;
},
Expand Down Expand Up @@ -653,6 +643,8 @@ const apis = ({ mixinConfig, viewProps, viewExternalAPI }) => {
addGetSet(mixinConfig, viewExternalAPI, viewProps);
};

const isDefined = value => value != null;

// add to state,
// add getters and setters to internal and external api (if not set)
// set initial state based on props in viewProps
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond.esm.min.js

Large diffs are not rendered by default.

46 changes: 19 additions & 27 deletions dist/filepond.js
@@ -1,5 +1,5 @@
/*!
* FilePond 4.13.1
* FilePond 4.13.2
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -373,11 +373,9 @@
var resting = false;

// updates spring state
var interpolate = function interpolate() {
var interpolate = function interpolate(ts, skipToEndState) {
// in rest, don't animate
if (resting) {
return;
}
if (resting) return;

// need at least a target or position to do springy things
if (!(isNumber(target) && isNumber(position))) {
Expand All @@ -399,7 +397,7 @@
velocity *= damping;

// we've arrived if we're near target and our velocity is near zero
if (thereYet(position, target, velocity)) {
if (thereYet(position, target, velocity) || skipToEndState) {
position = target;
velocity = 0;
resting = true;
Expand Down Expand Up @@ -499,30 +497,26 @@
var reverse = false;
var target = null;

var interpolate = function interpolate(ts) {
if (resting || target === null) {
return;
}
var interpolate = function interpolate(ts, skipToEndState) {
if (resting || target === null) return;

if (start === null) {
start = ts;
}

if (ts - start < delay) {
return;
}
if (ts - start < delay) return;

t = ts - start - delay;

if (t < duration) {
p = t / duration;
api.onupdate((t >= 0 ? easing(reverse ? 1 - p : p) : 0) * target);
} else {
if (t >= duration || skipToEndState) {
t = 1;
p = reverse ? 0 : 1;
api.onupdate(p * target);
api.oncomplete(p * target);
resting = true;
} else {
p = t / duration;
api.onupdate((t >= 0 ? easing(reverse ? 1 - p : p) : 0) * target);
}
};

Expand Down Expand Up @@ -627,10 +621,6 @@
});
};

var isDefined = function isDefined(value) {
return value != null;
};

// add to state,
// add getters and setters to internal and external api (if not set)
// setup animators
Expand All @@ -639,8 +629,7 @@
var mixinConfig = _ref.mixinConfig,
viewProps = _ref.viewProps,
viewInternalAPI = _ref.viewInternalAPI,
viewExternalAPI = _ref.viewExternalAPI,
viewState = _ref.viewState;
viewExternalAPI = _ref.viewExternalAPI;
// initial properties
var initialProps = Object.assign({}, viewProps);

Expand Down Expand Up @@ -688,12 +677,11 @@
// expose internal write api
return {
write: function write(ts) {
var skipToEndState = document.hidden;
var resting = true;
animations.forEach(function(animation) {
if (!animation.resting) {
resting = false;
}
animation.interpolate(ts);
if (!animation.resting) resting = false;
animation.interpolate(ts, skipToEndState);
});
return resting;
},
Expand Down Expand Up @@ -768,6 +756,10 @@
addGetSet(mixinConfig, viewExternalAPI, viewProps);
};

var isDefined = function isDefined(value) {
return value != null;
};

// add to state,
// add getters and setters to internal and external api (if not set)
// set initial state based on props in viewProps
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
@@ -1,6 +1,6 @@
{
"name": "filepond",
"version": "4.13.1",
"version": "4.13.2",
"description": "FilePond, Where files go to stretch their bits.",
"license": "MIT",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/app/actions.js
Expand Up @@ -748,7 +748,7 @@ export const actions = (dispatch, query, state) => ({
}),

PROCESS_ITEM: getItemByQueryFromState(state, (item, success, failure) => {

const maxParallelUploads = query('GET_MAX_PARALLEL_UPLOADS');
const totalCurrentUploads = query('GET_ITEMS_BY_STATUS', ItemStatus.PROCESSING).length;

Expand Down
11 changes: 4 additions & 7 deletions src/js/app/frame/mixins/animations.js
@@ -1,7 +1,6 @@
import { createAnimator } from '../utils/createAnimator';
import { forin } from '../../../utils/forin';
import { addGetSet } from './utils/addGetSet';
import { isDefined } from '../../../utils/isDefined';

// add to state,
// add getters and setters to internal and external api (if not set)
Expand All @@ -11,8 +10,7 @@ export const animations = ({
mixinConfig,
viewProps,
viewInternalAPI,
viewExternalAPI,
viewState
viewExternalAPI
}) => {
// initial properties
const initialProps = { ...viewProps };
Expand Down Expand Up @@ -60,12 +58,11 @@ export const animations = ({
// expose internal write api
return {
write: ts => {
let skipToEndState = document.hidden;
let resting = true;
animations.forEach(animation => {
if (!animation.resting) {
resting = false;
}
animation.interpolate(ts);
if (!animation.resting) resting = false;
animation.interpolate(ts, skipToEndState);
});
return resting;
},
Expand Down
8 changes: 3 additions & 5 deletions src/js/app/frame/utils/animators/spring.js
Expand Up @@ -30,12 +30,10 @@ export const spring =
let resting = false;

// updates spring state
const interpolate = () => {
const interpolate = (ts, skipToEndState) => {

// in rest, don't animate
if (resting) {
return;
}
if (resting) return;

// need at least a target or position to do springy things
if (!(isNumber(target) && isNumber(position))) {
Expand All @@ -57,7 +55,7 @@ export const spring =
velocity *= damping;

// we've arrived if we're near target and our velocity is near zero
if (thereYet(position, target, velocity)) {
if (thereYet(position, target, velocity) || skipToEndState) {
position = target;
velocity = 0;
resting = true;
Expand Down
23 changes: 10 additions & 13 deletions src/js/app/frame/utils/animators/tween.js
Expand Up @@ -13,33 +13,30 @@ export const tween =
let reverse = false;
let target = null;

const interpolate = ts => {
if (resting || target === null) {
return;
}
const interpolate = (ts, skipToEndState) => {
if (resting || target === null) return;

if (start === null) {
start = ts;
}

if (ts - start < delay) {
return;
}
if (ts - start < delay) return;

t = ts - start - delay;

if (t < duration) {
p = t / duration;
api.onupdate(
(t >= 0 ? easing(reverse ? 1 - p : p) : 0) * target
);
} else {
if (t >= duration || skipToEndState) {
t = 1;
p = reverse ? 0 : 1;
api.onupdate(p * target);
api.oncomplete(p * target);
resting = true;
}
else {
p = t / duration;
api.onupdate(
(t >= 0 ? easing(reverse ? 1 - p : p) : 0) * target
);
}
};

// need 'api' to call onupdate callback
Expand Down
1 change: 1 addition & 0 deletions src/js/app/utils/createFileProcessor.js
Expand Up @@ -122,6 +122,7 @@ export const createFileProcessor = processFn => {

// actual processing progress
(computable, current, total) => {

// update actual duration
state.duration = Date.now() - state.timestamp;

Expand Down

0 comments on commit b2ff1f4

Please sign in to comment.