mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Offline-toggling fix
- Fixed issue where offline-toggling incremented listener number, infine
This commit is contained in:
@@ -121,9 +121,10 @@ module.exports = function() {
|
|||||||
query: {"_id": coll},
|
query: {"_id": coll},
|
||||||
update: {$pull: {users: guid}},
|
update: {$pull: {users: guid}},
|
||||||
upsert: true,
|
upsert: true,
|
||||||
}, function(err, updated) {
|
}, function(err, updated, d) {
|
||||||
if(updated.nModified > 0) {
|
if(d.n == 1) {
|
||||||
io.to(coll).emit("viewers", updated.users);
|
io.to(coll).emit("viewers", updated.users.length);
|
||||||
|
db.collection("frontpage_lists").update({"_id": coll, "viewers": {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) { });
|
||||||
db.collection("connected_users").update({"_id": "total_users", total_users: {$gt: 0}}, {$inc: {total_users: -1}}, function(err, docs){
|
db.collection("connected_users").update({"_id": "total_users", total_users: {$gt: 0}}, {$inc: {total_users: -1}}, function(err, docs){
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {
|
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {
|
||||||
if(docs.nModified == 1) {
|
if(docs.nModified == 1) {
|
||||||
@@ -140,6 +141,9 @@ module.exports = function() {
|
|||||||
} else {
|
} else {
|
||||||
offline = false;
|
offline = false;
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) {
|
db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) {
|
||||||
|
if(docs.n && docs.n == 1) {
|
||||||
|
db.collection("connected_users").update({"_id": "total_users", "total_users": {$gt: 0}}, {$inc: {total_users: -1}}, function(err, docs){});
|
||||||
|
}
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user