Fire 'ext.echo.badge.countChange' after DOM changes

The event should fire after the count actually changes in the
DOM as well as the internal workings of Echo.

Change-Id: I03f1742b209305080af8784632f07dff63135d81
This commit is contained in:
Moriel Schottlender 2017-03-30 15:06:14 -07:00
parent 4a9cf5b2e2
commit 5c35535f36

View file

@ -52,17 +52,17 @@
mw.echo.ui.BadgeLinkWidget.prototype.setCount = function ( numItems, label ) { mw.echo.ui.BadgeLinkWidget.prototype.setCount = function ( numItems, label ) {
label = label || numItems; label = label || numItems;
this.$element
.toggleClass( 'mw-echo-notifications-badge-all-read', !numItems )
.toggleClass( 'mw-echo-notifications-badge-long-label', label.length > 2 )
.attr( 'data-counter-num', numItems )
.attr( 'data-counter-text', label );
if ( this.count !== numItems ) { if ( this.count !== numItems ) {
this.count = numItems; this.count = numItems;
// Fire badge count change hook // Fire badge count change hook
mw.hook( 'ext.echo.badge.countChange' ).fire( this.type, this.count, label ); mw.hook( 'ext.echo.badge.countChange' ).fire( this.type, this.count, label );
} }
this.$element
.toggleClass( 'mw-echo-notifications-badge-all-read', !numItems )
.toggleClass( 'mw-echo-notifications-badge-long-label', label.length > 2 )
.attr( 'data-counter-num', numItems )
.attr( 'data-counter-text', label );
}; };
}( mediaWiki, jQuery ) ); }( mediaWiki, jQuery ) );