fixed topics bug that was prevent /latest /popular /active and subsequently the admin versions of those routes from working. removed debug statements. added admin socket room. added dynamic updating of active users on acp index

v1.18.x
psychobunny 12 years ago
parent 30323fa29f
commit 09c9d0ee1f

@ -182,6 +182,7 @@ var socket,
app.current_room = null;
app.enter_room = function(room) {
console.log(room)
if (app.current_room === room) return;
socket.emit('event:enter_room', {

@ -24,6 +24,7 @@
}, false);
});
}())
</script>

@ -26,17 +26,19 @@
socket.on('api:get_all_rooms', function(data) {
var active_users = document.getElementById('active_users'),
total = 0;
active_users.innerHTML = '';
for(var room in data) {
if (room !== '') {
var count = data[room].length;
total += count;
active_users.innerHTML = active_users.innerHTML + "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div><br />";
active_users.innerHTML = active_users.innerHTML + "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>";
}
}
document.getElementById('connections').innerHTML = total;
});
app.enter_room('admin');
socket.emit('api:get_all_rooms');
</script>

@ -140,7 +140,7 @@ var RDB = require('./redis.js'),
// Global Topics
if (uid == null) uid = 0;
if (uid !== null) {
RDB.lpush('topics:tid', tid);
RDB.db.sadd('topics:tid', tid);
} else {
// need to add some unique key sent by client so we can update this with the real uid later
RDB.lpush('topics:queued:tid', tid);

@ -66,7 +66,6 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
});
socket.on('api:get_all_rooms', function(data) {
console.log('recieve');
socket.emit('api:get_all_rooms', io.sockets.manager.rooms);
})
@ -102,6 +101,8 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
});
});
if (data.enter != 'admin') io.sockets.in('admin').emit('api:get_all_rooms', io.sockets.manager.rooms);
});
// BEGIN: API calls (todo: organize)

Loading…
Cancel
Save