Jdlrobson has uploaded a new change for review.

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


Change subject: Improve error handling when location lookup fails
......................................................................

Improve error handling when location lookup fails

Do not try again, simply stop and complain.

Change-Id: If76c98e4843863d007e506dad27c5f0e7509dd11
---
M MobileFrontend.i18n.php
M includes/Resources.php
M includes/specials/SpecialNearby.php
M javascripts/specials/nearby.js
M templates/articleList.html
5 files changed, 22 insertions(+), 11 deletions(-)


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

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 3c52400..19f8fd9 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -124,7 +124,7 @@
        'mobile-frontend-nearby-requirements' => 'This page requires both 
JavaScript and a location aware browser.',
        'mobile-frontend-nearby-distance' => '{{PLURAL:$1|$1 km}}',
        'mobile-frontend-nearby-distance-meters' => '{{PLURAL:$1|$1 m}}',
-       'mobile-frontend-nearby-lookup-error' => 'Unable to find you. Trying 
again…',
+       'mobile-frontend-nearby-lookup-ui-error' => 'Unable to find you. This 
could be due to a problem with your network or your GPS device.',
        'mobile-frontend-nearby-noresults' => 'You are in the middle of nowhere 
and we couldn\'t find any topics. Why not write one?',
        'mobile-frontend-nearby-refresh' => 'We found a more accurate location 
for you. Click here to refresh the list of nearby pages',
        'mobile-frontend-nearby-error' => 'An unexpected error occurred whilst 
trying to find pages nearby',
@@ -476,7 +476,7 @@
        'mobile-frontend-nearby-requirements' => 'Message shown to users who 
have no javascript or a browser that is not capable',
        'mobile-frontend-nearby-distance' => 'States distance to current 
location in kilometers',
        'mobile-frontend-nearby-distance-meters' => 'States distance to current 
location in meters for numbers less than 1km',
-       'mobile-frontend-nearby-lookup-error' => 'Error message that shows in 
toast notification when location was lost',
+       'mobile-frontend-nearby-lookup-ui-error' => 'Error message shown when 
location was not found',
        'mobile-frontend-nearby-noresults' => 'Message shown when nothing is 
nearby',
        'mobile-frontend-nearby-refresh' => 'Text of toast notification message 
shown when user moved and the list can be refreshed.',
        'mobile-frontend-nearby-error' => 'Text of generic error message when 
querying geodata api',
diff --git a/includes/Resources.php b/includes/Resources.php
index aa3eebc..0880311 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -537,7 +537,7 @@
                        'mobile-frontend-nearby-loading',
                        'mobile-frontend-nearby-distance',
                        'mobile-frontend-nearby-distance-meters',
-                       'mobile-frontend-nearby-lookup-error',
+                       'mobile-frontend-nearby-lookup-ui-error',
                        'mobile-frontend-nearby-noresults',
                        'mobile-frontend-nearby-link',
                        'mobile-frontend-needs-photo',
diff --git a/includes/specials/SpecialNearby.php 
b/includes/specials/SpecialNearby.php
index 6eb78b8..4ef0f3a 100644
--- a/includes/specials/SpecialNearby.php
+++ b/includes/specials/SpecialNearby.php
@@ -28,7 +28,7 @@
                        ) .
                        Html::element( 'div',
                                array(
-                                       'class' => 'noscript content error',
+                                       'class' => 'noscript content error 
alert',
                                ),
                                wfMessage( 
'mobile-frontend-nearby-requirements' )->escaped()
                        ) .
diff --git a/javascripts/specials/nearby.js b/javascripts/specials/nearby.js
index 53a90f2..8530808 100644
--- a/javascripts/specials/nearby.js
+++ b/javascripts/specials/nearby.js
@@ -35,19 +35,26 @@
 
 $( function() {
        var supported = M.supportsGeoLocation(),
-               popup = M.require( 'notifications' ),
                nav = M.require( 'navigation' ),
                View = M.require( 'view' ),
-               errorHtml = $( '#mw-mf-nearby' ).html(),
+               errorMessages = {
+                       location: mw.msg( 
'mobile-frontend-nearby-lookup-ui-error' ),
+                       // recycle it's already in html
+                       incompatible: $( '#mw-mf-nearby .noscript' ).html()
+               },
                curLocation,
                lastKnownLocation = M.settings.getUserSetting( 
CACHE_KEY_LAST_LOCATION ),
                cache = M.settings.saveUserSetting,
                lastSearchResult = M.settings.getUserSetting( CACHE_KEY_RESULTS 
),
                Nearby = View.extend( {
                        template: M.template.get( 'articleList' ),
-                       renderError: function() {
-                               this.$el.html( errorHtml );
-                               this.$( '.noscript' ).removeClass( 'noscript' );
+                       /**
+                        * Renders an error in the existing view
+                        *
+                        * @param {String} type A string that identifies a 
particular type of error message
+                        */
+                       renderError: function( type ) {
+                               this.render( { error: errorMessages[ type ] } );
                        },
                        openPage: function( ev ) {
                                // help back button work
@@ -192,10 +199,11 @@
                        completeRefresh();
                },
                function() {
-                       popup.show( mw.message( 
'mobile-frontend-nearby-lookup-error' ).plain(), 'toast' );
+                       overlay.renderError( 'location' );
                        completeRefresh();
                },
                {
+                       timeout: 10000,
                        enableHighAccuracy: true
                } );
        }
@@ -223,7 +231,7 @@
                        init();
                }
        } else {
-               overlay.renderError();
+               overlay.renderError( 'incompatible' );
        }
 
        menu = $( '<li>' ).appendTo( nav.getPageMenu() );
diff --git a/templates/articleList.html b/templates/articleList.html
index e2f8178..1f036f6 100644
--- a/templates/articleList.html
+++ b/templates/articleList.html
@@ -1,3 +1,6 @@
+{{#error}}
+<div class="content error alert">{{error}}</div>
+{{/error}}
 <ul class="mw-mf-watchlist-results a-to-z">
        {{#pages}}
        <li title="{{title}}">

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If76c98e4843863d007e506dad27c5f0e7509dd11
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to