From d9f697414f2cd772f56ed6fda720764ef6256ce0 Mon Sep 17 00:00:00 2001 From: bsitu Date: Fri, 5 Sep 2014 14:30:45 -0700 Subject: [PATCH] mw.echo.overlay.updateCount() no longer exists If you have an unread notifications not in the initial load of special page, clicking load more would throw an error Bug: 69714 Change-Id: I9af588780b2ab8481ba252ddc21bad0601de7a0b --- modules/special/ext.echo.special.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/special/ext.echo.special.js b/modules/special/ext.echo.special.js index eb92347d6..6d11ff851 100644 --- a/modules/special/ext.echo.special.js +++ b/modules/special/ext.echo.special.js @@ -122,7 +122,8 @@ * Mark notifications as read. */ markAsRead: function ( unread ) { - var api = new mw.Api(), that = this; + var newCount, rawCount, $badge, + api = new mw.Api(), that = this; api.post( mw.echo.desktop.appendUseLang( { 'action' : 'echomarkread', @@ -131,9 +132,18 @@ } ) ).done( function ( result ) { // update the badge if the link is enabled if ( result.query.echomarkread.count !== undefined && - $( '#pt-notifications').length && typeof mw.echo.overlay === 'object' + $( '#pt-notifications').length ) { - mw.echo.overlay.updateCount( result.query.echomarkread.count, result.query.echomarkread.rawcount ); + newCount = result.query.echomarkread.count; + rawCount = result.query.echomarkread.rawcount; + $badge = mw.echo.getBadge(); + $badge.text( newCount ); + + if ( rawCount !== '0' && rawCount !== 0 ) { + $badge.addClass( 'mw-echo-unread-notifications' ); + } else { + $badge.removeClass( 'mw-echo-unread-notifications' ); + } } that.onSuccess(); } ).fail( function () {