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