Fixed when it is changing song twice

This commit is contained in:
Kasper Rynning-Tønnesen
2015-04-16 12:17:45 +02:00
parent adcc846f03
commit f2a059a1a3

View File

@@ -324,7 +324,7 @@ function vote(coll, id, guid, socket)
}
function change_song(coll)
function change_song(coll, id)
{
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs[0]["removeplay"] == true)
@@ -335,15 +335,27 @@ function change_song(coll)
})
}else
{
db.collection(coll).update({now_playing:true},
{$set:{
now_playing:false,
votes:0,
guids:[]
}}, function(err, docs)
{
change_song_post(coll);
});
if(id === undefined){
db.collection(coll).update({now_playing:true},
{$set:{
now_playing:false,
votes:0,
guids:[]
}}, function(err, docs)
{
change_song_post(coll);
});
}else{
db.collection(coll).update({now_playing:true, id:id},
{$set:{
now_playing:false,
votes:0,
guids:[]
}}, function(err, docs)
{
change_song_post(coll);
});
}
}
})
}