mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Trying small fix for null-viewers bug
This commit is contained in:
@@ -52,7 +52,11 @@ var Functions = {
|
|||||||
if(updated.nModified > 0) {
|
if(updated.nModified > 0) {
|
||||||
db.collection("connected_users").find({"_id": coll}, function(err, new_doc) {
|
db.collection("connected_users").find({"_id": coll}, function(err, new_doc) {
|
||||||
db.collection("frontpage_lists").update({"_id": coll}, {$set: {"viewers": new_doc[0].users.length}}, function(){
|
db.collection("frontpage_lists").update({"_id": coll}, {$set: {"viewers": new_doc[0].users.length}}, function(){
|
||||||
io.to(coll).emit("viewers", new_doc[0].users.length);
|
if(new_doc[0].users == undefined || new_doc[0].users.length == undefined) {
|
||||||
|
io.to(coll).emit("viewers", 1);
|
||||||
|
} else {
|
||||||
|
io.to(coll).emit("viewers", new_doc[0].users.length);
|
||||||
|
}
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
socket.broadcast.to(coll).emit('chat', {from: docs[0].name, msg: " joined"});
|
socket.broadcast.to(coll).emit('chat', {from: docs[0].name, msg: " joined"});
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ var list = function(msg, guid, coll, offline, socket) {
|
|||||||
socket.join(coll);
|
socket.join(coll);
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
io.to(coll).emit("viewers", frontpage_lists.viewers);
|
if(frontpage_lists.viewers != undefined){
|
||||||
|
io.to(coll).emit("viewers", frontpage_lists.viewers);
|
||||||
|
} else {
|
||||||
|
io.to(coll).emit("viewers", 1);
|
||||||
|
}
|
||||||
|
|
||||||
send_list(coll, socket, true, false, true);
|
send_list(coll, socket, true, false, true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user