Node.js based forum software built for the modern web
derpy globals to get notification pushing working for sockets on new notification event
Julian Lam2a829a061872
diff --git a/public/templates/footer.tpl b/public/templates/footer.tplindex 2cc7bc02e2..7a1c14d8e0 100644--- a/public/templates/footer.tpl+++ b/public/templates/footer.tpl@@ -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>diff --git a/src/notifications.js b/src/notifications.jsindex 3eb6ff4dd2..8ea7dc9f24 100644--- a/src/notifications.js+++ b/src/notifications.js@@ -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]);diff --git a/src/websockets.js b/src/websockets.jsindex 4af2a7f28d..7b31b5b3de 100644--- a/src/websockets.js+++ b/src/websockets.js@@ -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