mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-13 21:03:16 +02:00
derpy globals to get notification pushing working for sockets on new notification event
This commit is contained in:
@@ -138,6 +138,10 @@
|
||||
if (counts.unread > 0) notifIcon.className = 'icon-circle active';
|
||||
else notifIcon.className = 'icon-circle-blank';
|
||||
});
|
||||
socket.on('event:new_notification', function() {
|
||||
console.log('WOOT');
|
||||
document.querySelector('.notifications a i').className = 'icon-circle active';
|
||||
});
|
||||
socket.emit('api:notifications.counts');
|
||||
}());
|
||||
</script>
|
||||
|
||||
@@ -55,6 +55,7 @@ var config = require('../config.js'),
|
||||
(function(uid) {
|
||||
Notifications.remove_by_uniqueId(notif_data.uniqueId, uid, function() {
|
||||
RDB.zadd('uid:' + uid + ':notifications:unread', notif_data.score, nid);
|
||||
global.io.sockets.in('uid_' + uid).emit('event:new_notification');
|
||||
if (callback) callback(true);
|
||||
});
|
||||
})(uids[x]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
||||
var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
cookie = require('cookie'),
|
||||
connect = require('connect'),
|
||||
config = require('../config.js'),
|
||||
@@ -57,6 +57,7 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
||||
userSockets[uid].push(socket);
|
||||
user.go_online(uid);
|
||||
|
||||
socket.join('uid_' + uid);
|
||||
|
||||
/*process.on('uncaughtException', function(err) {
|
||||
// handle the error safely
|
||||
|
||||
Reference in New Issue
Block a user