Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277713

Change subject: uw.controller.Step: Emit 'load' earlier, so that 
mw.UploadWizard#removeErrorUploads works
......................................................................

uw.controller.Step: Emit 'load' earlier, so that 
mw.UploadWizard#removeErrorUploads works

We have this event handler defined in mw.UploadWizard:

        deeds: new uw.controller.Deed( this.api, this.config )
                .on( 'load', function () {
                        wizard.removeErrorUploads();
                } ),

But here, before we we emitted 'load', we did this:

        $.each( this.uploads, function ( i, upload ) {
                if ( upload !== undefined ) {
                        upload.state = step.stepName;
                }
        } );

This would clear the 'error' state from each upload (replacing it
with 'deeds'), and so none of the errored upload would be removed.
They would then inevitably fail in the Details step, where they
can't be removed.

This is very brittle, maybe we can do this in a different way later.

Change-Id: I89095f07e97fed9255a43ecf3a9191b541b51dab
---
M resources/controller/uw.controller.Step.js
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/13/277713/1

diff --git a/resources/controller/uw.controller.Step.js 
b/resources/controller/uw.controller.Step.js
index 10084e4..c1fbef6 100644
--- a/resources/controller/uw.controller.Step.js
+++ b/resources/controller/uw.controller.Step.js
@@ -82,6 +82,10 @@
 
                this.movedFrom = false;
 
+               // Through some very convoluted route, this reached code in 
mw.UploadWizard that can
+               // remove items from the `uploads` array here.
+               this.emit( 'load' );
+
                this.uploads = uploads || [];
 
                // Keep the uploads sorted in the order they were created in 
initially.
@@ -105,7 +109,6 @@
                this.ui.moveTo( uploads );
                ( new mw.UploadWizardTutorialEvent( 'load' ) ).dispatch();
                uw.eventFlowLogger.logStep( this.stepName );
-               this.emit( 'load' );
 
                this.updateFileCounts( this.uploads );
        };

-- 
To view, visit https://gerrit.wikimedia.org/r/277713
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I89095f07e97fed9255a43ecf3a9191b541b51dab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to