mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-28 10:19:50 +01:00
closes #1180
This commit is contained in:
@@ -8,13 +8,11 @@ define(['notifications', 'chat'], function(Notifications, Chat) {
|
||||
Chat.prepareDOM();
|
||||
translator.prepareDOM();
|
||||
|
||||
function updateUnreadCount(err, tids) {
|
||||
var count = 0, unreadEl = $('#unread-count');
|
||||
function updateUnreadCount(err, count) {
|
||||
var unreadEl = $('#unread-count');
|
||||
|
||||
if (err) {
|
||||
console.warn('Error updating unread count', err);
|
||||
} else if(tids && tids.length) {
|
||||
count = tids.length;
|
||||
}
|
||||
|
||||
unreadEl
|
||||
|
||||
@@ -101,7 +101,7 @@ SocketTopics.markAllRead = function(socket, data, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
index.server.sockets.in('uid_' + socket.uid).emit('event:unread.updateCount', null, []);
|
||||
index.server.sockets.in('uid_' + socket.uid).emit('event:unread.updateCount', null, 0);
|
||||
|
||||
callback();
|
||||
});
|
||||
|
||||
@@ -214,7 +214,7 @@ SocketUser.getOnlineAnonCount = function(socket, data, callback) {
|
||||
};
|
||||
|
||||
SocketUser.getUnreadCount = function(socket, data, callback) {
|
||||
topics.getUnreadTids(socket.uid, 0, 19, callback);
|
||||
topics.getTotalUnread(socket.uid, callback);
|
||||
};
|
||||
|
||||
SocketUser.getActiveUsers = function(socket, data, callback) {
|
||||
|
||||
@@ -559,8 +559,8 @@ var async = require('async'),
|
||||
};
|
||||
|
||||
Topics.getTotalUnread = function(uid, callback) {
|
||||
Topics.getUnreadTids(uid, 0, 21, function(err, tids) {
|
||||
callback(err, {count: tids ? tids.length : 0});
|
||||
Topics.getUnreadTids(uid, 0, 20, function(err, tids) {
|
||||
callback(err, tids ? tids.length : 0);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -574,7 +574,7 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
async.whilst(function() {
|
||||
return unreadTids.length < 20 && !done;
|
||||
return unreadTids.length < 21 && !done;
|
||||
}, function(callback) {
|
||||
Topics.getLatestTids(start, stop, 'month', function(err, tids) {
|
||||
if (err) {
|
||||
@@ -671,8 +671,8 @@ var async = require('async'),
|
||||
});
|
||||
|
||||
async.each(uids, function(uid, next) {
|
||||
Topics.getUnreadTids(uid, 0, 19, function(err, tids) {
|
||||
websockets.in('uid_' + uid).emit('event:unread.updateCount', null, tids);
|
||||
Topics.getTotalUnread(uid, function(err, count) {
|
||||
websockets.in('uid_' + uid).emit('event:unread.updateCount', null, count);
|
||||
next();
|
||||
});
|
||||
}, function(err) {
|
||||
|
||||
Reference in New Issue
Block a user