Fixed issue with client vote/add and such

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-23 17:54:43 +01:00
parent 264948a88a
commit 3048527635
4 changed files with 13 additions and 6 deletions

View File

@@ -278,13 +278,14 @@ function del_ajax(id) {
url: "/api/list/" + chan.toLowerCase() + "/" + id,
success: function(response) {
toast("deletesong");
get_list_ajax();
},
error: function(response) {
if(response.responseJSON.status == 403) {
start_auth();
toast("listhaspass");
} else if(response.responseJSON.status == 429) {
setTimeout(function() {
vote_ajax(id);
del_ajax(id);
}, response.getResponseHeader("Retry-After") * 1000);
}
}
@@ -310,9 +311,12 @@ function add_ajax(id, title, duration, playlist, num, full_num, start, end) {
url: "/api/list/" + chan.toLowerCase() + "/" + id,
success: function(response) {
toast("addedsong");
get_list_ajax();
},
error: function(response) {
if(response.responseJSON.status == 409) {
if(response.responseJSON.status == 403) {
toast("listhaspass");
} else if(response.responseJSON.status == 409) {
vote_ajax(id);
} else if(response.responseJSON.status == 429) {
setTimeout(function() {
@@ -338,10 +342,11 @@ function vote_ajax(id) {
url: "/api/list/" + chan.toLowerCase() + "/" + id,
success: function(response) {
toast("voted");
get_list_ajax();
},
error: function(response) {
if(response.responseJSON.status == 403) {
start_auth();
toast("listhaspass");
} else if(response.responseJSON.status == 429) {
setTimeout(function() {
vote_ajax(id);
@@ -391,6 +396,7 @@ function setup_youtube_listener(){
function get_list_listener(){
socket.on("get_list", function(){
var add = "";
socket_connected = true;
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
/*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
if(p == undefined) p = "";*/

View File

@@ -548,7 +548,7 @@ var List = {
},
vote: function(id, vote) {
if(client && !socket.connected) {
if(client && !socket_connected) {
if(vote != "del") {
vote_ajax(id);
} else {

View File

@@ -5,6 +5,7 @@ var client = false;
if(domain.length > 0 && domain[0] == "client") {
client = true;
}
var socket_connected = false;
var hasadmin = 0;
var list_html = $("#list-song-html").html();
var unseen = false;

View File

@@ -463,7 +463,7 @@ var Search = {
},
submit: function(id,title,duration, playlist, num, full_num, start, end){
if(client && !socket.connected) {
if(client && !socket_connected) {
add_ajax(id, title, duration, playlist, num, full_num, start, end);
return;
}