Reword skipping in channel, allowing the whole channel to be skipped each second

This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-29 10:36:44 +02:00
parent ae05344aa1
commit 695a4f3648
2 changed files with 29 additions and 30 deletions

View File

@@ -452,7 +452,8 @@ function checkTimeout(type, timeout, channel, guid, conf_pass, this_pass, socket
var retry_in = (date.getTime() - now.getTime()) / 1000;
if(retry_in > 0) {
if(error_message) {
socket.emit("toast", error_message + Math.ceil(retry_in) + " seconds.");
var sOrNot = Math.ceil(retry_in) > 1 || Math.ceil(retry_in) == 0 ? "s" : "";
socket.emit("toast", error_message + Math.ceil(retry_in) + " second" + sOrNot + ".");
} else {
socket.emit("toast", "wait_longer");
}

View File

@@ -197,9 +197,6 @@ function skip(list, guid, coll, offline, socket) {
}
hash = adminpass;
var toCompare = list.error
var connection_id = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]);
Functions.checkTimeout("skip", 1, coll, connection_id, error, true, socket, function() {
//db.collection(coll + "_settings").find(function(err, docs){
if(docs !== null && docs.length !== 0)
@@ -211,6 +208,7 @@ function skip(list, guid, coll, offline, socket) {
(frontpage_viewers[0].viewers == 2 && docs[0].skips.length+1 == 2 && !Functions.contains(docs[0].skips, guid)) ||
(docs[0].adminpass == hash && docs[0].adminpass !== "" && docs[0].skip))
{
Functions.checkTimeout("skip", 1, coll, coll, error, true, socket, function() {
change_song(coll, error, video_id, docs);
socket.emit("toast", "skip");
db.collection("user_names").find({"guid": guid}, function(err, docs) {
@@ -224,6 +222,7 @@ function skip(list, guid, coll, offline, socket) {
});
}
});
}, "The channel is skipping too often, please wait ");
}else if(!Functions.contains(docs[0].skips, guid)){
db.collection(coll + "_settings").update({ id: "config" }, {$push:{skips:guid}}, function(err, d){
if(frontpage_viewers[0].viewers == 2)
@@ -240,7 +239,6 @@ function skip(list, guid, coll, offline, socket) {
}else
socket.emit("toast", "noskip");
}
});
//});
} else {
socket.emit("auth_required");