mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Merge "Display a message when API fail due to session end"
This commit is contained in:
commit
76ea1746f9
|
@ -199,6 +199,7 @@ $wgResourceModules += array(
|
|||
),
|
||||
'messages' => array(
|
||||
'echo-api-failure',
|
||||
'echo-notification-loginrequired',
|
||||
'echo-api-failure-cross-wiki',
|
||||
),
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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' ) )
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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' );
|
||||
|
|
Loading…
Reference in a new issue