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

Change subject: Alpha: Add watchlist star to nearby view
......................................................................


Alpha: Add watchlist star to nearby view

Note previously if one of the pages didn't exist no
watch stars would render
Made adjustments to watch star code to allow for this

If using $wgMFNearbyEndpoint you will need to make one of
the nearby articles on the endpoint present in your local wiki

Change-Id: Id14d8653333b99d3449bb652ae69cbc40a2d083b
---
M javascripts/modules/mf-watchstar.js
M javascripts/specials/nearby.js
2 files changed, 16 insertions(+), 9 deletions(-)

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



diff --git a/javascripts/modules/mf-watchstar.js 
b/javascripts/modules/mf-watchstar.js
index 99a8af3..f24ec0d 100644
--- a/javascripts/modules/mf-watchstar.js
+++ b/javascripts/modules/mf-watchstar.js
@@ -129,16 +129,14 @@
                        }
                } ).done( function( data ) {
                                var pages = data.query.pages,
-                                       notEmpty = !pages[ '-1' ], statuses = 
{}, page, i;
+                                       statuses = {}, page, i;
                                for( i in pages ) {
-                                       if( pages.hasOwnProperty( i ) ) {
+                                       if( pages.hasOwnProperty( i ) && i > -1 
) { // if i is < 0 then the page doesn't exist in the wiki
                                                page = pages[ i ];
                                                statuses[ page.title ] = 
page.hasOwnProperty( 'watched' );
                                        }
                                }
-                               if( notEmpty ) {
-                                       callback( statuses );
-                               }
+                               callback( statuses );
                } );
        }
 
@@ -205,11 +203,15 @@
                                var title = $( this ).attr( 'title' );
                                createWatchListButton( this, title, true );
                        } );
-               } else {
-                       checkWatchStatus( titles, function( status ) {
+               } else if ( M.isLoggedIn() && titles.length > 0 ) {
+                       checkWatchStatus( titles, function( statuses ) {
                                $container.find( 'li' ).each( function() {
-                                       var title = $( this ).attr( 'title' );
-                                       createWatchListButton( this, title, 
status[ title ] );
+                                       var title = $( this ).attr( 'title' ),
+                                               status = statuses[ title ];
+
+                                       if ( status !== undefined ) {
+                                               createWatchListButton( this, 
title, status );
+                                       }
                                } );
                        } );
                }
diff --git a/javascripts/specials/nearby.js b/javascripts/specials/nearby.js
index c1fc3d0..cddff3a 100644
--- a/javascripts/specials/nearby.js
+++ b/javascripts/specials/nearby.js
@@ -5,6 +5,7 @@
 
 ( function() {
        var supported = M.supportsGeoLocation(),
+               watchstar = M.require( 'watchstar' ),
                popup = M.require( 'notifications' ),
                View = M.require( 'view' ),
                endpoint = mw.config.get( 'wgMFNearbyEndpoint' ),
@@ -13,6 +14,7 @@
                lastKnownLocation = M.settings.getUserSetting( 
CACHE_KEY_LAST_LOCATION ),
                cache = M.settings.saveUserSetting,
                lastSearchResult = M.settings.getUserSetting( CACHE_KEY_RESULTS 
),
+               inAlpha = mw.config.get( 'wgMFMode' ) === 'alpha', // FIXME: 
sandbox before pushing nearby to stable
                Nearby = View.extend( {
                        template: M.template.get( 'articleList' ),
                        initialize: function() {
@@ -22,6 +24,9 @@
                                        $.cookie( 'mwUploadsFunnel', 'nearby', 
{ expires: new Date( new Date().getTime() + 60000) } );
                                        self.emit( 'page-click', ev );
                                } );
+                               if ( inAlpha ) {
+                                       watchstar.initWatchListIconList( 
this.$( 'ul' ) );
+                               }
                        }
                } ),
                overlay = new Nearby( {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id14d8653333b99d3449bb652ae69cbc40a2d083b
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to