Skip to content

Commit 35dfc7b

Browse files
committed
fix problem where local files couldn't be edited and would not trigger remove action on upload
1 parent 4a7ba37 commit 35dfc7b

File tree

10 files changed

+85
-14
lines changed

10 files changed

+85
-14
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.28.2
4+
5+
- Fix issue where local server files could not be re-uploaded after editing and did not trigger remove of source file.
6+
37
## 4.28.1
48

59
- Fix CSS error.

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.28.1
2+
* FilePond 4.28.2
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: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.28.1
2+
* FilePond 4.28.2
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -3857,7 +3857,7 @@ const createItem = (origin = null, serverFileReference = null, file = null) => {
38573857

38583858
const api = {
38593859
id: { get: () => id },
3860-
origin: { get: () => origin },
3860+
origin: { get: () => origin, set: value => (origin = value) },
38613861
serverId: { get: () => state.serverFileReference },
38623862
transferId: { get: () => state.transferId },
38633863
status: { get: () => state.status },
@@ -4127,6 +4127,15 @@ const actions = (dispatch, query, state) => ({
41274127
return;
41284128
}
41294129

4130+
// if is local item we need to enable upload button so change can be propagated to server
4131+
if (item.origin === FileOrigin.LOCAL) {
4132+
dispatch('DID_LOAD_ITEM', {
4133+
id: item.id,
4134+
error: null,
4135+
serverFileReference: item.source,
4136+
});
4137+
}
4138+
41304139
// for async scenarios
41314140
const upload = () => {
41324141
// we push this forward a bit so the interface is updated correctly
@@ -4756,6 +4765,16 @@ const actions = (dispatch, query, state) => ({
47564765
success(createItemAPI(item));
47574766
processNext();
47584767

4768+
// if origin is local, and we're instant uploading, trigger remove of original
4769+
// as revert will remove file from list
4770+
const server = state.options.server;
4771+
const instantUpload = state.options.instantUpload;
4772+
if (instantUpload && item.origin === FileOrigin.LOCAL && isFunction(server.remove)) {
4773+
const noop = () => {};
4774+
item.origin = FileOrigin.LIMBO;
4775+
state.options.server.remove(item.source, noop, noop);
4776+
}
4777+
47594778
// All items processed? No errors?
47604779
const allItemsProcessed =
47614780
query('GET_ITEMS_BY_STATUS', ItemStatus.PROCESSING_COMPLETE).length ===
@@ -4836,7 +4855,8 @@ const actions = (dispatch, query, state) => ({
48364855
success(createItemAPI(item));
48374856
};
48384857

4839-
// if this is a local file and the server.remove function has been configured, send source there so dev can remove file from server
4858+
// if this is a local file and the `server.remove` function has been configured,
4859+
// send source there so dev can remove file from server
48404860
const server = state.options.server;
48414861
if (
48424862
item.origin === FileOrigin.LOCAL &&

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: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePond 4.28.1
2+
* FilePond 4.28.2
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -6065,6 +6065,9 @@
60656065
get: function get() {
60666066
return origin;
60676067
},
6068+
set: function set(value) {
6069+
return (origin = value);
6070+
},
60686071
},
60696072
serverId: {
60706073
get: function get() {
@@ -6428,6 +6431,15 @@
64286431
return;
64296432
}
64306433

6434+
// if is local item we need to enable upload button so change can be propagated to server
6435+
if (item.origin === FileOrigin.LOCAL) {
6436+
dispatch('DID_LOAD_ITEM', {
6437+
id: item.id,
6438+
error: null,
6439+
serverFileReference: item.source,
6440+
});
6441+
}
6442+
64316443
// for async scenarios
64326444
var upload = function upload() {
64336445
// we push this forward a bit so the interface is updated correctly
@@ -7131,6 +7143,20 @@
71317143
success(createItemAPI(item));
71327144
processNext();
71337145

7146+
// if origin is local, and we're instant uploading, trigger remove of original
7147+
// as revert will remove file from list
7148+
var server = state.options.server;
7149+
var instantUpload = state.options.instantUpload;
7150+
if (
7151+
instantUpload &&
7152+
item.origin === FileOrigin.LOCAL &&
7153+
isFunction(server.remove)
7154+
) {
7155+
var noop = function noop() {};
7156+
item.origin = FileOrigin.LIMBO;
7157+
state.options.server.remove(item.source, noop, noop);
7158+
}
7159+
71347160
// All items processed? No errors?
71357161
var allItemsProcessed =
71367162
query('GET_ITEMS_BY_STATUS', ItemStatus.PROCESSING_COMPLETE).length ===
@@ -7220,7 +7246,8 @@
72207246
success(createItemAPI(item));
72217247
};
72227248

7223-
// if this is a local file and the server.remove function has been configured, send source there so dev can remove file from server
7249+
// if this is a local file and the `server.remove` function has been configured,
7250+
// send source there so dev can remove file from server
72247251
var server = state.options.server;
72257252
if (
72267253
item.origin === FileOrigin.LOCAL &&

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

src/js/app/actions.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ export const actions = (dispatch, query, state) => ({
168168
return;
169169
}
170170

171+
// if is local item we need to enable upload button so change can be propagated to server
172+
if (item.origin === FileOrigin.LOCAL) {
173+
dispatch('DID_LOAD_ITEM', {
174+
id: item.id,
175+
error: null,
176+
serverFileReference: item.source,
177+
});
178+
}
179+
171180
// for async scenarios
172181
const upload = () => {
173182
// we push this forward a bit so the interface is updated correctly
@@ -797,6 +806,16 @@ export const actions = (dispatch, query, state) => ({
797806
success(createItemAPI(item));
798807
processNext();
799808

809+
// if origin is local, and we're instant uploading, trigger remove of original
810+
// as revert will remove file from list
811+
const server = state.options.server;
812+
const instantUpload = state.options.instantUpload;
813+
if (instantUpload && item.origin === FileOrigin.LOCAL && isFunction(server.remove)) {
814+
const noop = () => {};
815+
item.origin = FileOrigin.LIMBO;
816+
state.options.server.remove(item.source, noop, noop);
817+
}
818+
800819
// All items processed? No errors?
801820
const allItemsProcessed =
802821
query('GET_ITEMS_BY_STATUS', ItemStatus.PROCESSING_COMPLETE).length ===
@@ -877,7 +896,8 @@ export const actions = (dispatch, query, state) => ({
877896
success(createItemAPI(item));
878897
};
879898

880-
// if this is a local file and the server.remove function has been configured, send source there so dev can remove file from server
899+
// if this is a local file and the `server.remove` function has been configured,
900+
// send source there so dev can remove file from server
881901
const server = state.options.server;
882902
if (
883903
item.origin === FileOrigin.LOCAL &&

src/js/app/utils/createItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export const createItem = (origin = null, serverFileReference = null, file = nul
387387

388388
const api = {
389389
id: { get: () => id },
390-
origin: { get: () => origin },
390+
origin: { get: () => origin, set: value => (origin = value) },
391391
serverId: { get: () => state.serverFileReference },
392392
transferId: { get: () => state.transferId },
393393
status: { get: () => state.status },

0 commit comments

Comments
 (0)