mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-07 11:21:51 +02:00
integrated Tinycon lib and actually fixed notification counts... heh.
closed #610
This commit is contained in:
@@ -113,6 +113,10 @@
|
||||
socket.emit('api:notifications.mark_all_read', null, function() {
|
||||
notifIcon.toggleClass('active', false);
|
||||
utils.refreshTitle();
|
||||
|
||||
// Update favicon + local count
|
||||
Tinycon.setBubble(0);
|
||||
localStorage.setItem('notifications:count', 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -137,7 +141,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('api:notifications.getCount', function(count) {
|
||||
socket.emit('api:notifications.getCount', function(err, count) {
|
||||
// Update notification icon, if necessary
|
||||
if (count > 0) {
|
||||
notifIcon.toggleClass('active', true);
|
||||
@@ -145,10 +149,18 @@
|
||||
notifIcon.toggleClass('active', false);
|
||||
}
|
||||
|
||||
// Update the saved local count
|
||||
localStorage.setItem('notifications:count', count);
|
||||
Tinycon.setBubble(localStorage.getItem('notifications:count'));
|
||||
|
||||
// Update favicon
|
||||
Tinycon.setBubble(count);
|
||||
});
|
||||
|
||||
if (localStorage.getItem('notifications:count') !== null) {
|
||||
Tinycon.setBubble(localStorage.getItem('notifications:count'));
|
||||
}
|
||||
|
||||
socket.on('event:new_notification', function() {
|
||||
notifIcon.toggleClass('active', true);
|
||||
app.alert({
|
||||
@@ -159,6 +171,11 @@
|
||||
timeout: 2000
|
||||
});
|
||||
utils.refreshTitle();
|
||||
|
||||
// Update the favicon + local storage
|
||||
var savedCount = parseInt(localStorage.getItem('notifications:count'),10) || 0;
|
||||
localStorage.setItem('notifications:count', savedCount+1);
|
||||
Tinycon.setBubble(savedCount+1);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1009,7 +1009,7 @@ var bcrypt = require('bcrypt'),
|
||||
});
|
||||
},
|
||||
getUnreadCount: function(uid, callback) {
|
||||
RDB.zcount('uid:' + uid + ':notifications:unread', 0, 10, callback);
|
||||
RDB.zcount('uid:' + uid + ':notifications:unread', -Infinity, Infinity, callback);
|
||||
},
|
||||
getUnreadByUniqueId: function(uid, uniqueId, callback) {
|
||||
RDB.zrange('uid:' + uid + ':notifications:unread', 0, -1, function(err, nids) {
|
||||
|
||||
@@ -669,6 +669,13 @@ websockets.init = function(io) {
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:notifications.getCount', function(callback) {
|
||||
console.log('checking uid', uid);
|
||||
user.notifications.getUnreadCount(uid, function(err, count) {
|
||||
callback(err ? err.message : null, count);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:categories.getRecentReplies', function(tid) {
|
||||
categories.getRecentReplies(tid, 4, function(replies) {
|
||||
socket.emit('api:categories.getRecentReplies', replies);
|
||||
|
||||
Reference in New Issue
Block a user