From e4b79c1bc25b5d0e493836501a1e4aa210b9413a Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 22 Jun 2016 17:11:34 +0100 Subject: [PATCH] Use the actual total notification count in the special page sidebar Adding up numbers in the front-end is not enough, because it could be that not all pages are listed (it's a top 10). So get the total count from the backend. Change-Id: Ibbc76691ef88333b92132a514fdba3cde3797e10 --- includes/api/ApiEchoUnreadNotificationPages.php | 5 ++++- modules/model/mw.echo.dm.SourcePagesModel.js | 10 ++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/includes/api/ApiEchoUnreadNotificationPages.php b/includes/api/ApiEchoUnreadNotificationPages.php index 35136c05c..a0fa9181e 100644 --- a/includes/api/ApiEchoUnreadNotificationPages.php +++ b/includes/api/ApiEchoUnreadNotificationPages.php @@ -88,7 +88,10 @@ class ApiEchoUnreadNotificationPages extends ApiCrossWikiBase { ); } - return array( 'pages' => $result ); + return array( + 'pages' => $result, + 'totalCount' => MWEchoNotifUser::newFromUser( $this->getUser() )->getLocalNotificationCount(), + ); } /** diff --git a/modules/model/mw.echo.dm.SourcePagesModel.js b/modules/model/mw.echo.dm.SourcePagesModel.js index c5f679f03..d71927e52 100644 --- a/modules/model/mw.echo.dm.SourcePagesModel.js +++ b/modules/model/mw.echo.dm.SourcePagesModel.js @@ -189,18 +189,17 @@ * @param {Object} details Details object */ mw.echo.dm.SourcePagesModel.prototype.setSourcePagesDetails = function ( source, details ) { - var id, pageDetails, count; + var id, pageDetails; // Source information this.sources[ source ] = { title: details.source.title, base: details.source.base, - totalCount: 0, + totalCount: details.totalCount, pages: {} }; // Fill in pages - count = 0; for ( id in details.pages ) { pageDetails = details.pages[ id ]; this.sources[ source ].pages[ id ] = { @@ -208,11 +207,6 @@ count: pageDetails.count, id: id }; - - count += parseInt( pageDetails.count ); } - - // Update total count - this.sources[ source ].totalCount = count; }; } )( mediaWiki );