Merge "Display a message when API fail due to session end"

This commit is contained in:
jenkins-bot 2016-08-29 23:46:59 +00:00 committed by Gerrit Code Review
commit 76ea1746f9
5 changed files with 50 additions and 6 deletions

View file

@ -199,6 +199,7 @@ $wgResourceModules += array(
),
'messages' => array(
'echo-api-failure',
'echo-notification-loginrequired',
'echo-api-failure-cross-wiki',
),
'targets' => array( 'desktop', 'mobile' ),

View file

@ -226,7 +226,16 @@
controller.manager.getLocalCounter().update();
return dateItemIds;
} );
} )
.then(
null,
function ( errCode, errObj ) {
return {
errCode: errCode,
errInfo: OO.getProp( errObj, 'error', 'info' )
};
}
);
};
/**
* Fetch notifications from the local API and update the notifications list.

View file

@ -357,8 +357,14 @@
}
},
// Failure
function () {
widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-api-failure' ) );
function ( errorObj ) {
if ( errorObj.errCode === 'notlogin-required' ) {
// Login required message
widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-notification-loginrequired' ) );
} else {
// Generic API failure message
widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-api-failure' ) );
}
}
)
.then( this.emit.bind( this, 'finishLoading' ) )

View file

@ -29,6 +29,8 @@
this.$overlay = config.$overlay || this.$element;
this.limit = config.limit || 25;
this.error = false;
// A notice or error message widget
this.noticeMessageWidget = new OO.ui.LabelWidget( {
classes: [ 'mw-echo-ui-notificationsInboxWidget-notice' ]
@ -236,6 +238,7 @@
}
this.pushPending();
this.error = false;
return fetchPromise
.then(
// Success
@ -245,8 +248,21 @@
widget.controller.updateSeenTimeForCurrentSource();
},
// Failure
this.popPending.bind( this )
);
function ( errObj ) {
var msg;
if ( errObj.errCode === 'notlogin-required' ) {
// Login required message
msg = mw.msg( 'echo-notification-loginrequired' );
} else {
// Generic API failure message
msg = mw.msg( 'echo-api-failure' );
}
widget.error = true;
widget.noticeMessageWidget.setLabel( msg );
widget.displayMessage( true );
}
)
.always( this.popPending.bind( this ) );
};
/**
@ -265,7 +281,10 @@
* Extend the popPending method to enable UI elements
*/
mw.echo.ui.NotificationsInboxWidget.prototype.popPending = function () {
this.resetMessageLabel();
if ( !this.error ) {
this.resetMessageLabel();
}
this.topPaginationWidget.setDisabled( false );
this.bottomPaginationWidget.setDisabled( false );

View file

@ -65,6 +65,15 @@
this.pushPending();
return this.controller.fetchLocalNotifications( true )
.then( null, function ( errorObj ) {
if ( errorObj.errCode === 'notlogin-required' ) {
// Login required message
widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-notification-loginrequired' ) );
} else {
// Generic API failure message
widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-api-failure' ) );
}
} )
.always( function () {
widget.popPending();
widget.emit( 'finishLoading' );