JGonera has uploaded a new change for review.

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


Change subject: Evict demons from uploads tutorial on iOS
......................................................................

Evict demons from uploads tutorial on iOS

Showing the tutorial overlay in Safari triggered a scroll event which
in turn triggered an empty event of PhotoList which created another
tutorial overlay which then again triggered a scroll event, etc.

Bug: 50201
Change-Id: I0385440102abe4c83b8f4cc453e8ab936dd00d0e
---
M javascripts/specials/uploads.js
1 file changed, 10 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/55/70955/1

diff --git a/javascripts/specials/uploads.js b/javascripts/specials/uploads.js
index de064e7..cf2c643 100644
--- a/javascripts/specials/uploads.js
+++ b/javascripts/specials/uploads.js
@@ -70,7 +70,7 @@
                initialize: function() {
                        // how close a spinner needs to be to the viewport to 
trigger loading (px)
                        this.threshold = 1000;
-                       this.loading = false;
+                       this.shouldLoad = true;
                        this.api = new UserGalleryApi();
                        this._super();
                },
@@ -101,22 +101,26 @@
                _loadPhotos: function() {
                        var self = this;
 
-                       if ( this._isEndNear() && !this.loading ) {
-                               this.loading = true;
+                       if ( this.shouldLoad && this._isEndNear() ) {
+                               // don't try to load more until current request 
is finished
+                               this.shouldLoad = false;
 
-                               this.api.getPhotos().always( function() {
-                                       self.loading = false;
-                               } ).done( function( photos ) {
+                               this.api.getPhotos().done( function( photos ) {
                                        if ( photos.length ) {
                                                $.each( photos, function() {
                                                        self.appendPhoto( this 
);
                                                } );
+                                               // try loading more when end is 
near only if we got photos last time
+                                               self.shouldLoad = true;
                                        } else {
                                                self.$end.remove();
                                                if ( self.isEmpty() ) {
                                                        self.emit( 'empty' );
                                                }
                                        }
+                               } ).fail( function() {
+                                       // try loading again if request failed
+                                       self.shouldLoad = true;
                                } );
                        }
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0385440102abe4c83b8f4cc453e8ab936dd00d0e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: JGonera <jgon...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to