mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 22:25:27 +00:00
Move error handling inside Minerva
ReferenceDrawer Instead of doing this inside the ReferenceDrawer component itself, we'll do this here. To be backwards compatible we check the value is truthy. When I5a7b23f60722eb5017a85c68f38844dd460f8b63 is merged this can be removed. For NotificationBadge we pass the onError option which is now available and allows us to clean up the NotificationBadge Change-Id: I47db11fa945a05f3b2a9a43c3cf053ca489a38fa
This commit is contained in:
parent
22ca1e5f39
commit
71bf8604ab
|
@ -27,6 +27,10 @@
|
|||
options.title = $el.find( 'a' ).attr( 'title' );
|
||||
options.url = $el.find( 'a' ).attr( 'href' );
|
||||
count = Number( $el.find( 'span' ).data( 'notification-count' ) );
|
||||
options.onError = function () {
|
||||
// FIXME: Blocked on T189173. Ideally we'd use the router here.
|
||||
window.location.href = this.getNotificationURL();
|
||||
}.bind( this );
|
||||
}
|
||||
View.call( this, options );
|
||||
this.url = options.url;
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
var drawer,
|
||||
skin = M.require( 'skins.minerva.scripts/skin' ),
|
||||
page = M.getCurrentPage(),
|
||||
router = require( 'mediawiki.router' ),
|
||||
util = M.require( 'mobile.startup/util' ),
|
||||
ReferencesGateway = M.require( 'mobile.references.gateway/ReferencesGateway' ),
|
||||
ReferencesMobileViewGateway = M.require(
|
||||
'mobile.references.gateway/ReferencesMobileViewGateway'
|
||||
),
|
||||
|
@ -40,7 +43,7 @@
|
|||
* @param {Page} page
|
||||
*/
|
||||
function showReference( ev, drawer, page ) {
|
||||
var urlComponents,
|
||||
var urlComponents, result,
|
||||
$dest = $( ev.currentTarget ),
|
||||
href = $dest.attr( 'href' );
|
||||
|
||||
|
@ -52,7 +55,16 @@
|
|||
if ( urlComponents.length > 1 ) {
|
||||
href = '#' + urlComponents[1];
|
||||
}
|
||||
drawer.showReference( href, page, $dest.text() );
|
||||
result = drawer.showReference( href, page, $dest.text() );
|
||||
// Previously showReference method returns nothing so we check its truthy
|
||||
// Can be removed when I5a7b23f60722eb5017a85c68f38844dd460f8b63 is merged.
|
||||
if ( result ) {
|
||||
result.then( util.noop, function ( err ) {
|
||||
if ( err === ReferencesGateway.ERROR_NOT_EXIST ) {
|
||||
router.navigate( href );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// don't hide drawer (stop propagation of click) if it is already shown
|
||||
// (e.g. click another reference)
|
||||
|
|
Loading…
Reference in a new issue