Retry button remains visible when initiating a retry programmatically #1455

Closed
Korijn opened this Issue Aug 14, 2015 · 2 comments

Projects

None yet

2 participants

@Korijn
Contributor
Korijn commented Aug 14, 2015

For example, when applying the following mechanism to arrange for endless retries, the Retry button remains visible, even after the upload succeeds.

uploader = new qq.azure.FineUploader({
    callbacks: {
        onStatusChange: function (id, oldStatus, newStatus) {
            if (newStatus === qq.status.UPLOAD_FAILED) {
                uploader.retry(id);
@Korijn
Contributor
Korijn commented Aug 14, 2015

After some initial inspection of the source, I think the onRetry event handler in uploader.api.js is not being called when a retry is scheduled programmatically, since it only appears to be wired up to the UI click event of the retry button.

This is the onRetry handler, which updates the UI:

onRetry: function(fileId) {
    qq(self._templating.getFileContainer(fileId)).removeClass(self._classes.retryable);
    self._templating.hideRetry(fileId);
    self.retry(fileId);
},

It looks like my hypothesis is correct when looking at the _manualRetry method in uploader.basic.api.js:

/**
 * Conditionally orders a manual retry of a failed upload.
 *
 * @param id File ID of the failed upload
 * @param callback Optional callback to invoke if a retry is prudent.
 * In lieu of asking the upload handler to retry.
 * @returns {boolean} true if a manual retry will occur
 * @private
 */
_manualRetry: function(id, callback) {
    if (this._onBeforeManualRetry(id)) {
        this._netUploadedOrQueued++;
        this._uploadData.setStatus(id, qq.status.UPLOAD_RETRYING);

        if (callback) {
            callback(id);
        }
        else {
            this._handler.retry(id);
        }

        return true;
    }
},

I'm not sure how to call the event handler from this piece of code, or alternatively how to trigger the event manually. Can you give me a hint, @rnicholus?

@rnicholus
Member

The easiest solution is probably just add a call to the hideRetry method of the templating module to the qq.status.UPLOAD_RETRYING check in the _onUploadStausChange method. You can then remove any other code that duplicates this logic on retry.

@rnicholus rnicholus added this to the 5.3.1 milestone Aug 28, 2015
@rnicholus rnicholus closed this in ccd8910 Aug 28, 2015
@rnicholus rnicholus removed the 5 - Done label Sep 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment