From 2a829a061872f8d87eba3a24a71121d16c219a06 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 23 May 2013 15:53:55 -0400 Subject: [PATCH 1/2] derpy globals to get notification pushing working for sockets on new notification event --- public/templates/footer.tpl | 4 ++++ src/notifications.js | 1 + src/websockets.js | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/templates/footer.tpl b/public/templates/footer.tpl index 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'); }()); diff --git a/src/notifications.js b/src/notifications.js index 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.js index 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 From d71a38c4f76df5ddcca683e26c17d2e58c632427 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 23 May 2013 16:03:45 -0400 Subject: [PATCH 2/2] minor styling changes to notif window --- public/css/style.less | 7 ++++++- public/templates/header.tpl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index 0cf52a6dfd..6a93c9c4de 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -759,7 +759,12 @@ body .navbar .nodebb-inline-block { #notif-list { li { font-size: 12px; - width: 200px; + width: 300px; + text-align: left; + + a { + white-space: normal; + } &.unread { background: #eceff5; diff --git a/public/templates/header.tpl b/public/templates/header.tpl index f6de74602a..9fe341423b 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -47,7 +47,7 @@