jenkins-bot has submitted this change and it was merged.

Change subject: Prevent the badge icon from flashing red when updating 
notifications
......................................................................


Prevent the badge icon from flashing red when updating notifications

If the popup is open, whatever is coming in is immediately 'seen',
so we shouldn't flash the badge as red.

Bug: T112823
Change-Id: I9fe78ed11506de3c82043141f994e1ca96c5880b
---
M modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
1 file changed, 23 insertions(+), 6 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js 
b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
index 3ae932b..da4aa83 100644
--- a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
+++ b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
@@ -38,6 +38,7 @@
                this.markReadWhenSeen = !!config.markReadWhenSeen;
                this.badgeIcon = config.badgeIcon || {};
                this.hasRunFirstTime = false;
+               this.currentUnreadCountInBadge = 0;
 
                buttonFlags = [ 'primary' ];
                if ( !!config.hasUnseen ) {
@@ -200,12 +201,26 @@
                        unreadCount = this.notificationsModel.getUnreadCount();
 
                // Update numbers and seen/unseen state
-               this.badgeButton.setFlags( { unseen: !!unseenCount } );
-               this.badgeButton.setLabel( mw.language.convertNumber( 
unreadCount ) );
-               this.updateIcon( !!unseenCount );
+               // If the popup is open, only allow a "demotion" of the badge
+               // to grey; ignore change of color to 'unseen'
+               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
                this.markAllReadButton.toggle( !!unreadCount );
+               this.currentUnreadCountInBadge = unreadCount;
        };
 
        /**
@@ -244,13 +259,15 @@
                                        
mw.echo.logger.logNotificationImpressions( this.type, idArray, 
mw.echo.Logger.static.context.popup );
 
                                        // // Mark notifications as 'read' if 
markReadWhenSeen is set to true
-                                       if ( widget.markReadWhenSeen ) {
+                                       if ( widget.popup.isVisible() && 
widget.markReadWhenSeen ) {
                                                return 
widget.notificationsModel.markAllRead();
                                        }
                                } )
                                .then( function () {
-                                       // Update seen time
-                                       
widget.notificationsModel.updateSeenTime();
+                                       if ( widget.popup.isVisible() ) {
+                                               // Update seen time
+                                               
widget.notificationsModel.updateSeenTime();
+                                       }
                                } )
                                .then(
                                        // Success

-- 
To view, visit https://gerrit.wikimedia.org/r/240294
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9fe78ed11506de3c82043141f994e1ca96c5880b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to