Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file listener changeProgress state never reaches uploaded #22

Open
MakotoNinja opened this issue May 18, 2021 · 0 comments
Open

file listener changeProgress state never reaches uploaded #22

MakotoNinja opened this issue May 18, 2021 · 0 comments

Comments

@MakotoNinja
Copy link

MakotoNinja commented May 18, 2021

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant