Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 2815317

Browse files
committed
fixing notification count being off
1 parent e565e7a commit 2815317

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

js/views/pageNavVw.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,13 @@ module.exports = baseVw.extend({
9090
});
9191

9292
this.unreadNotifsViaSocket = 0;
93+
this.fetchNotifsMarkedAsRead = 0;
9394

94-
this.listenTo(this.notificationsCl, 'reset update', (cl, options) => {
95-
if (options.xhr) this.unreadNotifsViaSocket = 0;
95+
this.listenTo(this.notificationsCl, 'reset update', function(cl, options) {
96+
if (options.xhr) {
97+
this.fetchNotifsMarkedAsRead = 0;
98+
this.unreadNotifsViaSocket = 0;
99+
}
96100

97101
this.setNotificationCount(this.getUnreadNotifCount());
98102
});
@@ -164,7 +168,7 @@ module.exports = baseVw.extend({
164168

165169
this.notificationsCl.add(
166170
__.extend({}, notif, { read: false })
167-
)
171+
);
168172

169173
//prevent message spamming from one user
170174
if(!this.notificationsRecord[username]){
@@ -374,7 +378,8 @@ module.exports = baseVw.extend({
374378
},
375379

376380
getUnreadNotifCount: function() {
377-
return (this.unreadNotifsViaSocket + this.notificationsCl.getUnreadCount()) || 0;
381+
return this.unreadNotifsViaSocket + this.notificationsCl.getUnreadCount() -
382+
this.fetchNotifsMarkedAsRead || 0;
378383
},
379384

380385
onNotifMenuOpen: function() {
@@ -407,7 +412,9 @@ module.exports = baseVw.extend({
407412
});
408413
}
409414

410-
this.setNotificationCount(0);
415+
this.fetchNotifsMarkedAsRead += unread.length - this.unreadNotifsViaSocket;
416+
this.unreadNotifsViaSocket = 0;
417+
this.setNotificationCount(this.getUnreadNotifCount());
411418
},
412419

413420
onPopMenuNavClick: function(e) {

0 commit comments

Comments
 (0)