Skip to content

Commit 2fd9ce6

Browse files
committed
fix priority of options
1 parent 653007d commit 2fd9ce6

9 files changed

Lines changed: 97 additions & 24 deletions

File tree

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.30.1
4+
5+
- Prioritize server prop before other props when passed to setOptions #606
6+
37
## 4.30.0
48

59
- Add `labelFileSizeBytes`, `labelFileSizeKilobytes`, `labelFileSizeMegabytes`, `labelFileSizeGigabytes` #763

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.30.0
2+
* FilePond 4.30.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: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.30.0
2+
* FilePond 4.30.1
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -4992,12 +4992,36 @@ const actions = (dispatch, query, state) => ({
49924992
}),
49934993

49944994
SET_OPTIONS: ({ options }) => {
4995-
forin(options, (key, value) => {
4996-
dispatch(`SET_${fromCamels(key, '_').toUpperCase()}`, { value });
4995+
// get all keys passed
4996+
const optionKeys = Object.keys(options);
4997+
4998+
// get prioritized keyed to include (remove once not in options object)
4999+
const prioritizedOptionKeys = PrioritizedOptions.filter(key => optionKeys.includes(key));
5000+
5001+
// order the keys, prioritized first, then rest
5002+
const orderedOptionKeys = [
5003+
// add prioritized first if passed to options, else remove
5004+
...prioritizedOptionKeys,
5005+
5006+
// prevent duplicate keys
5007+
...Object.keys(options).filter(key => !prioritizedOptionKeys.includes(key)),
5008+
];
5009+
5010+
console.log(orderedOptionKeys);
5011+
5012+
// dispatch set event for each option
5013+
orderedOptionKeys.forEach(key => {
5014+
dispatch(`SET_${fromCamels(key, '_').toUpperCase()}`, {
5015+
value: options[key],
5016+
});
49975017
});
49985018
},
49995019
});
50005020

5021+
const PrioritizedOptions = [
5022+
'server', // must be processed before "files"
5023+
];
5024+
50015025
const formatFilename = name => name;
50025026

50035027
const createElement$1 = tagName => {

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: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.30.0
2+
* FilePond 4.30.1
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -7395,13 +7395,38 @@
73957395

73967396
SET_OPTIONS: function SET_OPTIONS(_ref11) {
73977397
var options = _ref11.options;
7398-
forin(options, function(key, value) {
7399-
dispatch('SET_' + fromCamels(key, '_').toUpperCase(), { value: value });
7398+
// get all keys passed
7399+
var optionKeys = Object.keys(options);
7400+
7401+
// get prioritized keyed to include (remove once not in options object)
7402+
var prioritizedOptionKeys = PrioritizedOptions.filter(function(key) {
7403+
return optionKeys.includes(key);
7404+
});
7405+
7406+
// order the keys, prioritized first, then rest
7407+
var orderedOptionKeys = [].concat(
7408+
_toConsumableArray(prioritizedOptionKeys),
7409+
_toConsumableArray(
7410+
Object.keys(options).filter(function(key) {
7411+
return !prioritizedOptionKeys.includes(key);
7412+
})
7413+
)
7414+
);
7415+
7416+
console.log(orderedOptionKeys);
7417+
7418+
// dispatch set event for each option
7419+
orderedOptionKeys.forEach(function(key) {
7420+
dispatch('SET_' + fromCamels(key, '_').toUpperCase(), {
7421+
value: options[key],
7422+
});
74007423
});
74017424
},
74027425
};
74037426
};
74047427

7428+
var PrioritizedOptions = ['server'];
7429+
74057430
var formatFilename = function formatFilename(name) {
74067431
return name;
74077432
};

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

src/js/app/actions.js

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,14 @@ export const actions = (dispatch, query, state) => ({
928928
);
929929
} else {
930930
// if is requesting revert and can revert need to call revert handler (not calling request_ because that would also trigger beforeRemoveHook)
931-
if ((options.revert && item.origin !== FileOrigin.LOCAL && item.serverId !== null) ||
931+
if (
932+
(options.revert && item.origin !== FileOrigin.LOCAL && item.serverId !== null) ||
932933
// if chunked uploads are enabled and we're uploading in chunks for this specific file
933934
// or if the file isn't big enough for chunked uploads but chunkForce is set then call
934935
// revert before removing from the view...
935-
(state.options.chunkUploads && (item.file.size > state.options.chunkSize)) ||
936-
(state.options.chunkUploads && state.options.chunkForce)) {
936+
(state.options.chunkUploads && item.file.size > state.options.chunkSize) ||
937+
(state.options.chunkUploads && state.options.chunkForce)
938+
) {
937939
item.revert(
938940
createRevertFunction(state.options.server.url, state.options.server.revert),
939941
query('GET_FORCE_REVERT')
@@ -1014,14 +1016,32 @@ export const actions = (dispatch, query, state) => ({
10141016
}),
10151017

10161018
SET_OPTIONS: ({ options }) => {
1017-
// specify option keys that need to be processed before the others (internal order is preserved)
1018-
const prioritizedOptions = [
1019-
'server', // must be processed before "files"
1020-
].filter(value => value in options);
1021-
1022-
// loop through all keys in options, but prioritizedOptions first
1023-
[...new Set([...prioritizedOptions,...Object.keys(options)])].forEach((optionKey) => {
1024-
dispatch(`SET_${fromCamels(optionKey, '_').toUpperCase()}`, { value: options[optionKey] });
1019+
// get all keys passed
1020+
const optionKeys = Object.keys(options);
1021+
1022+
// get prioritized keyed to include (remove once not in options object)
1023+
const prioritizedOptionKeys = PrioritizedOptions.filter(key => optionKeys.includes(key));
1024+
1025+
// order the keys, prioritized first, then rest
1026+
const orderedOptionKeys = [
1027+
// add prioritized first if passed to options, else remove
1028+
...prioritizedOptionKeys,
1029+
1030+
// prevent duplicate keys
1031+
...Object.keys(options).filter(key => !prioritizedOptionKeys.includes(key)),
1032+
];
1033+
1034+
console.log(orderedOptionKeys);
1035+
1036+
// dispatch set event for each option
1037+
orderedOptionKeys.forEach(key => {
1038+
dispatch(`SET_${fromCamels(key, '_').toUpperCase()}`, {
1039+
value: options[key],
1040+
});
10251041
});
10261042
},
10271043
});
1044+
1045+
const PrioritizedOptions = [
1046+
'server', // must be processed before "files"
1047+
];

0 commit comments

Comments
 (0)