Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
fix(uploader.basic.api.js): onStatusChange called too early
Browse files Browse the repository at this point in the history
onStatusChange is called for initial/canned files before internal state for the file is completely updated. This change introduces an update that makes it easy for internal users of the upload-data service to defer the status change broadcast until all processing and state updates are complete.
fixes #1802
fixes FineUploader/react-fine-uploader#91
  • Loading branch information
rnicholus authored Apr 6, 2017
1 parent 2c86cbb commit 7cd87b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 2 additions & 0 deletions client/js/upload-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ qq.UploadData = function(uploaderProxy) {
* - status: Initial `qq.status` for this file. Omit for `qq.status.SUBMITTING`.
* - batchId: ID of the batch this file belongs to
* - proxyGroupId: ID of the proxy group associated with this file
* - onBeforeStatusChange(fileId): callback that is executed before the status change is broadcast
*
* @returns {number} Internal ID for this file.
*/
Expand Down Expand Up @@ -104,6 +105,7 @@ qq.UploadData = function(uploaderProxy) {
}
byStatus[status].push(id);

spec.onBeforeStatusChange && spec.onBeforeStatusChange(id);
uploaderProxy.onStatusChange(id, null, status);

return id;
Expand Down
27 changes: 14 additions & 13 deletions client/js/uploader.basic.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,24 +442,25 @@
qq.basePrivateApi = {
// Updates internal state with a file record (not backed by a live file). Returns the assigned ID.
_addCannedFile: function(sessionData) {
var id = this._uploadData.addFile({
var self = this;

return this._uploadData.addFile({
uuid: sessionData.uuid,
name: sessionData.name,
size: sessionData.size,
status: qq.status.UPLOAD_SUCCESSFUL
});

sessionData.deleteFileEndpoint && this.setDeleteFileEndpoint(sessionData.deleteFileEndpoint, id);
sessionData.deleteFileParams && this.setDeleteFileParams(sessionData.deleteFileParams, id);

if (sessionData.thumbnailUrl) {
this._thumbnailUrls[id] = sessionData.thumbnailUrl;
}
status: qq.status.UPLOAD_SUCCESSFUL,
onBeforeStatusChange: function(id) {
sessionData.deleteFileEndpoint && self.setDeleteFileEndpoint(sessionData.deleteFileEndpoint, id);
sessionData.deleteFileParams && self.setDeleteFileParams(sessionData.deleteFileParams, id);

this._netUploaded++;
this._netUploadedOrQueued++;
if (sessionData.thumbnailUrl) {
self._thumbnailUrls[id] = sessionData.thumbnailUrl;
}

return id;
self._netUploaded++;
self._netUploadedOrQueued++;
}
});
},

_annotateWithButtonId: function(file, associatedInput) {
Expand Down
2 changes: 1 addition & 1 deletion client/js/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/*global qq */
qq.version = "5.14.1";
qq.version = "5.14.2";
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Fine Uploader",
"main": "lib/traditional.js",
"types" : "typescript/fine-uploader.d.ts",
"version": "5.14.1",
"version": "5.14.2",
"description": "Multiple file upload plugin with progress-bar, drag-and-drop, direct-to-S3 & Azure uploading, client-side image scaling, preview generation, form support, chunking, auto-resume, and tons of other features.",
"keywords": [
"amazon",
Expand Down

0 comments on commit 7cd87b5

Please sign in to comment.