jenkins-bot has submitted this change and it was merged.

Change subject: Remove references to upload in FirefoggTransport
......................................................................


Remove references to upload in FirefoggTransport

Bug: T77124
Change-Id: Ief906848344d2986ddc28a095f9470b2b6299325
---
M resources/mw.FirefoggHandler.js
M resources/mw.FirefoggTransport.js
2 files changed, 42 insertions(+), 33 deletions(-)

Approvals:
  Gilles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/mw.FirefoggHandler.js b/resources/mw.FirefoggHandler.js
index 550f6d7..5ef0bdf 100644
--- a/resources/mw.FirefoggHandler.js
+++ b/resources/mw.FirefoggHandler.js
@@ -22,21 +22,50 @@
                },
 
                getTransport: function () {
-                       var upload = this.upload;
+                       var file, transport,
+                               handler = this,
+                               fogg = this.getFogg(),
+                               upload = this.upload,
+                               $fileInput = upload.ui.$fileInputCtrl[0];
+
+                       if ( $fileInput.files && $fileInput.files.length ) {
+                               file = $fileInput.files[0];
+                       } else if ( upload.file ) {
+                               file = upload.file;
+                       } else if ( upload.providedFile ) {
+                               file = upload.providedFile;
+                       } else {
+                               mw.log.warn( 'Firefogg tried to upload a file 
but was unable to find one.' );
+                               return false;
+                       }
 
                        if ( !this.transport ) {
-                               this.transport = new mw.FirefoggTransport(
-                                       this.upload,
+                               transport = new mw.FirefoggTransport(
+                                       file,
                                        this.api,
-                                       this.getFogg()
+                                       fogg
                                ).on( 'progress', function ( data ) {
-                                       upload.setTransportProgress( 
data.progress );
-                                       // also update preview video, url is in 
data.preview
+                                       if ( upload.state === 'aborted' ) {
+                                               fogg.cancel();
+                                       } else {
+                                               upload.setTransportProgress( 
data.progress );
+                                               upload.ui.setStatus( 
'mwe-upwiz-encoding' );
+                                       }
                                } ).on( 'transported', function ( result ) {
                                        mw.log( 
'FirefoggTransport::getTransport> Transport done ' + JSON.stringify( result ) );
                                        upload.setTransported( result );
+                               } ).on( 'encoding', function () {
+                                       upload.ui.setStatus( 
'mwe-upwiz-encoding' );
+                               } ).on( 'starting', function ( file ) {
+                                       upload.ui.setStatus( 
'mwe-upwiz-uploading' );
+                                       upload.file = file;
+                                       transport.uploadHandler = new 
mw.ApiUploadFormDataHandler( upload, handler.api );
+                                       transport.uploadHandler.start();
                                } );
+
+                               this.transport = transport;
                        }
+
                        return this.transport;
                },
 
diff --git a/resources/mw.FirefoggTransport.js 
b/resources/mw.FirefoggTransport.js
index ee17265..fa62737 100644
--- a/resources/mw.FirefoggTransport.js
+++ b/resources/mw.FirefoggTransport.js
@@ -6,14 +6,14 @@
         * @class mw.FirefoggTransport
         * @mixins OO.EventEmitter
         * @constructor
-        * @param {mw.UploadWizardUpload} upload
+        * @param {File} file
         * @param {mw.Api} api
         * @param {Firefogg} fogg Firefogg instance
         */
-       mw.FirefoggTransport = function ( upload, api, fogg ) {
+       mw.FirefoggTransport = function ( file, api, fogg ) {
                oo.EventEmitter.call( this );
 
-               this.upload = upload;
+               this.fileToUpload = file;
                this.api = api;
                this.fogg = fogg;
        };
@@ -26,24 +26,13 @@
         * Do an upload
         */
        FTP.doUpload = function () {
-               var fileToUpload, transport = this;
+               var fileToUpload = this.fileToUpload, transport = this;
 
                //Encode or passthrough Firefogg before upload
                if ( this.isUploadFormat() ) {
-                       if ( this.upload.ui.$fileInputCtrl[0].files && 
this.upload.ui.$fileInputCtrl[0].files.length ) {
-                               fileToUpload = 
this.upload.ui.$fileInputCtrl[0].files[0];
-                       } else if ( this.upload.file ) {
-                               fileToUpload = this.upload.file;
-                       } else if ( this.upload.providedFile ) {
-                               fileToUpload = this.upload.providedFile;
-                       } else {
-                               mw.log.warn( 'Firefogg tried to upload a file 
but was unable to find one.' );
-                               return false;
-                       }
-
                        this.doFormDataUpload( fileToUpload );
                } else {
-                       this.upload.ui.setStatus( 'mwe-upwiz-encoding' );
+                       this.emit( 'encoding' );
                        this.fogg.encode( JSON.stringify( 
this.getEncodeSettings() ),
                                function (result, file) {
                                        result = JSON.parse(result);
@@ -62,23 +51,14 @@
                                                transport.emit( 'transported', 
response );
                                        }
                                }, function ( progress ) { //progress
-                                       if ( transport.upload.state === 
'aborted' ) {
-                                               transport.fogg.cancel();
-                                       } else {
-                                               progress = JSON.parse(progress);
-                                               transport.emit( 'progress',  
progress );
-                                               transport.upload.ui.setStatus( 
'mwe-upwiz-encoding' );
-                                       }
+                                       transport.emit( 'progress', JSON.parse( 
progress ) );
                                }
                        );
                }
        };
 
        FTP.doFormDataUpload = function ( file ) {
-               this.upload.ui.setStatus( 'mwe-upwiz-uploading' );
-               this.upload.file = file;
-               this.uploadHandler = new mw.ApiUploadFormDataHandler( 
this.upload, this.api );
-               this.uploadHandler.start();
+               this.emit( 'starting', file );
        };
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ief906848344d2986ddc28a095f9470b2b6299325
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to