Skip to content

Commit 3792a64

Browse files
committed
MOBILE-2103 notifications: Fix update counter
1 parent 7f6cb92 commit 3792a64

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

www/addons/messages/services/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ angular.module('mm.addons.messages')
371371
}
372372

373373
function updateUnreadConversationsCount(siteId) {
374-
return $mmaMessages.getUnreadConversationsCount().then(function(unread) {
374+
siteId = siteId || $mmSite.getId();
375+
return $mmaMessages.getUnreadConversationsCount(undefined, siteId).then(function(unread) {
375376
// Leave badge enter if there is a 0+ or a 0.
376377
$scope.badge = parseInt(unread, 10) > 0 ? unread : '';
377378
// Update badge.

www/addons/notifications/services/handlers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angular.module('mm.addons.notifications')
2323
* @ngdoc service
2424
* @name $mmaNotificationsHandlers
2525
*/
26-
.factory('$mmaNotificationsHandlers', function($log, $mmaNotifications, $mmEvents, $mmSitesManager, $mmUtil,
26+
.factory('$mmaNotificationsHandlers', function($log, $mmaNotifications, $mmEvents, $mmSitesManager, $mmUtil, $mmSite,
2727
mmaNotificationsReadChangedEvent, mmaNotificationsReadCronEvent, $mmAddonManager) {
2828
$log = $log.getInstance('$mmaNotificationsHandlers');
2929

@@ -106,7 +106,8 @@ angular.module('mm.addons.notifications')
106106
}
107107

108108
function updateUnreadNotificationsCount(siteId) {
109-
return $mmaNotifications.getUnreadNotificationsCount().then(function(unread) {
109+
siteId = siteId || $mmSite.getId();
110+
return $mmaNotifications.getUnreadNotificationsCount(undefined, siteId).then(function(unread) {
110111
// Leave badge enter if there is a 0+ or a 0.
111112
$scope.badge = parseInt(unread, 10) > 0 ? unread : '';
112113
// Update badge.

www/addons/pushnotifications/services/pushnotifications.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ angular.module('mm.addons.pushnotifications')
260260
* @module mm.addons.pushnotifications
261261
* @ngdoc method
262262
* @name $mmaPushNotifications#updateAddonCounter
263-
* @param {String} siteId Site ID.
264-
* @param {String} addon Registered addon name to set the badge number.
265-
* @param {Number} number The number to be stored.
266-
* @return {Promise} Promise resolved with the stored badge counter for the addon on the site.
263+
* @param {String} [siteId] Site ID. If not defined, use current site.
264+
* @param {String} addon Registered addon name to set the badge number.
265+
* @param {Number} number The number to be stored.
266+
* @return {Promise} Promise resolved with the stored badge counter for the addon on the site.
267267
*/
268268
self.updateAddonCounter = function(siteId, addon, number) {
269269
if ($mmPushNotificationsDelegate.isCounterHandlerRegistered(addon)) {
@@ -403,12 +403,14 @@ angular.module('mm.addons.pushnotifications')
403403
/**
404404
* Save the addon/site badgecounter on the database.
405405
*
406-
* @param {String} siteId Site ID.
406+
* @param {String} [siteId] Site ID. If not defined, use current site.
407407
* @param {Number} number The number to be stored.
408408
* @param {String} [addon] Registered addon name. If not defined it will store the site total.
409409
* @return {Promise} Promise resolved with the stored badge counter for the addon or site.
410410
*/
411411
function saveAddonBadge(siteId, number, addon) {
412+
siteId = siteId || $mmSite.getId();
413+
412414
var entry = {
413415
siteid: siteId,
414416
addon: addon || 'site',

0 commit comments

Comments
 (0)