mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-01 02:46:46 +00:00
Merge "Prevent the badge icon from flashing red when updating notifications"
This commit is contained in:
commit
5d3a12335b
|
@ -38,6 +38,7 @@
|
||||||
this.markReadWhenSeen = !!config.markReadWhenSeen;
|
this.markReadWhenSeen = !!config.markReadWhenSeen;
|
||||||
this.badgeIcon = config.badgeIcon || {};
|
this.badgeIcon = config.badgeIcon || {};
|
||||||
this.hasRunFirstTime = false;
|
this.hasRunFirstTime = false;
|
||||||
|
this.currentUnreadCountInBadge = 0;
|
||||||
|
|
||||||
buttonFlags = [ 'primary' ];
|
buttonFlags = [ 'primary' ];
|
||||||
if ( !!config.hasUnseen ) {
|
if ( !!config.hasUnseen ) {
|
||||||
|
@ -200,12 +201,26 @@
|
||||||
unreadCount = this.notificationsModel.getUnreadCount();
|
unreadCount = this.notificationsModel.getUnreadCount();
|
||||||
|
|
||||||
// Update numbers and seen/unseen state
|
// Update numbers and seen/unseen state
|
||||||
this.badgeButton.setFlags( { unseen: !!unseenCount } );
|
// If the popup is open, only allow a "demotion" of the badge
|
||||||
this.badgeButton.setLabel( mw.language.convertNumber( unreadCount ) );
|
// to grey; ignore change of color to 'unseen'
|
||||||
this.updateIcon( !!unseenCount );
|
if ( this.popup.isVisible() ) {
|
||||||
|
if ( !unseenCount ) {
|
||||||
|
this.badgeButton.setFlags( { unseen: false } );
|
||||||
|
this.updateIcon( false );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.badgeButton.setFlags( { unseen: !!unseenCount } );
|
||||||
|
this.updateIcon( !!unseenCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update badge count
|
||||||
|
if ( !this.markReadWhenSeen || !this.popup.isVisible() || unreadCount < this.currentUnreadCountInBadge ) {
|
||||||
|
this.badgeButton.setLabel( mw.language.convertNumber( unreadCount ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we need to display the 'mark all unread' button
|
// Check if we need to display the 'mark all unread' button
|
||||||
this.markAllReadButton.toggle( !!unreadCount );
|
this.markAllReadButton.toggle( !!unreadCount );
|
||||||
|
this.currentUnreadCountInBadge = unreadCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,13 +259,15 @@
|
||||||
mw.echo.logger.logNotificationImpressions( this.type, idArray, mw.echo.Logger.static.context.popup );
|
mw.echo.logger.logNotificationImpressions( this.type, idArray, mw.echo.Logger.static.context.popup );
|
||||||
|
|
||||||
// // Mark notifications as 'read' if markReadWhenSeen is set to true
|
// // Mark notifications as 'read' if markReadWhenSeen is set to true
|
||||||
if ( widget.markReadWhenSeen ) {
|
if ( widget.popup.isVisible() && widget.markReadWhenSeen ) {
|
||||||
return widget.notificationsModel.markAllRead();
|
return widget.notificationsModel.markAllRead();
|
||||||
}
|
}
|
||||||
} )
|
} )
|
||||||
.then( function () {
|
.then( function () {
|
||||||
// Update seen time
|
if ( widget.popup.isVisible() ) {
|
||||||
widget.notificationsModel.updateSeenTime();
|
// Update seen time
|
||||||
|
widget.notificationsModel.updateSeenTime();
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
.then(
|
.then(
|
||||||
// Success
|
// Success
|
||||||
|
|
Loading…
Reference in a new issue