Skip to content

file listener changeProgress state never reaches uploaded #22

Description

@MakotoNinja

I have found that when listening to a file's changeProgress event, the file's state never becomes the final state of uploaded'. So something like the following will never execute the the code when the state is uploaded.

let uploader = new com.zenesis.qx.upload.UploadMgr(this.upload, uploadUrl);
uploader.addListener('addFile', function(evt) {
  let file = evt.getData();
  let progressListenerId = file.addListener('changeProgress', function(evt) {
    let file = evt.getTarget();
    let uploadedSize = evt.getData();
    if(file.getState() === 'uploading')
    {
      console.log('uploading...');
    }
    else if(file.getState() === 'uploaded')
    {
      // this is never executed...
      console.log('finished uploading!');
    }
  }
});

I have made a fix by firing the changeProgress data event in File.js _applyState function:

// property apply
_applyState: function(value, oldValue) {
  qx.core.Assert.assertTrue((!oldValue && value == "not-started")
    || (oldValue == "not-started" && (value == "cancelled" || value == "uploading"))
    || (oldValue == "uploading" && (value == "cancelled" || value == "uploaded")));
  // fire the event!
  this.fireDataEvent('changeProgress', value);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions