Remove orange bar when all talk notifications are read

Don't just remove it when all notifications are read, but when all
specifically talk notifications are read even if there are other
unread notifications in the popup.

Change-Id: I5aa65a4060d64f374b47fe91d8e53c92ded5fab2
This commit is contained in:
Moriel Schottlender 2015-10-01 10:56:40 -07:00
parent d27daff8cb
commit 55e9d8e819
2 changed files with 18 additions and 1 deletions

View file

@ -69,7 +69,7 @@
// Replace the link button with the ooui button
$existingMessageLink.parent().replaceWith( mw.echo.ui.messageWidget.$element );
mw.echo.ui.messageWidget.getModel().on( 'allRead', function () {
mw.echo.ui.messageWidget.getModel().on( 'allTalkRead', function () {
// If there was a talk page notification, get rid of it
$( '#pt-mytalk a' )
.removeClass( 'mw-echo-alert' )

View file

@ -127,6 +127,23 @@
if ( this.unreadNotifications.isEmpty() ) {
this.emit( 'allRead' );
}
if ( !this.countUnreadTalkPageNotifications() ) {
this.emit( 'allTalkRead' );
}
};
mw.echo.dm.NotificationsModel.prototype.countUnreadTalkPageNotifications = function () {
var i, len,
talk = 0,
items = this.unreadNotifications.getItems();
for ( i = 0, len = items.length; i < len; i++ ) {
if ( items[i].getCategory() === 'edit-user-talk' ) {
talk++;
}
}
return talk;
};
/**