Fixed issue with empty playlists

This commit is contained in:
Kasper Rynning-Tønnesen
2017-06-18 21:40:30 +02:00
parent 51dcb53aa5
commit 11d473373d
3 changed files with 17 additions and 15 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+11 -9
View File
@@ -49,9 +49,7 @@ var List = {
if (navigator.vibrate) { if (navigator.vibrate) {
navigator.vibrate(100); navigator.vibrate(100);
} }
} catch(e) { } catch(e) {}
//console.log(e);
}
$(".accept-delete").attr("data-video-id", $(this).attr("data-video-id")); $(".accept-delete").attr("data-video-id", $(this).attr("data-video-id"));
$("#delete_song_title").html($(this).find(".list-title").html()); $("#delete_song_title").html($(this).find(".list-title").html());
$("#delete_song_alert").modal("open"); $("#delete_song_alert").modal("open");
@@ -74,14 +72,8 @@ var List = {
} }
}); });
// record the initial position of the cursor on start of the touch
jqDraggableItem.on("touchstart", Helper.touchstart); jqDraggableItem.on("touchstart", Helper.touchstart);
// fires whenever the cursor moves
jqDraggableItem.on("touchmove", Helper.touchmove); jqDraggableItem.on("touchmove", Helper.touchmove);
// when the user lifts their finger, they will again need to meet the
// threshold before vertical scrolling starts.
jqDraggableItem.on("touchend", Helper.touchend); jqDraggableItem.on("touchend", Helper.touchend);
} }
} }
@@ -100,16 +92,22 @@ var List = {
if((!offline || (offline && !msg.shuffled)) && !(offline && prev_chan_list == chan)){ if((!offline || (offline && !msg.shuffled)) && !(offline && prev_chan_list == chan)){
prev_chan_list = chan; prev_chan_list = chan;
List.populate_list(msg.playlist); List.populate_list(msg.playlist);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
} else if(offline && prev_chan_list == chan && full_playlist != undefined && !msg.shuffled){ } else if(offline && prev_chan_list == chan && full_playlist != undefined && !msg.shuffled){
List.populate_list(full_playlist, true); List.populate_list(full_playlist, true);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
}
if(!w_p) List.dragging(true); if(!w_p) List.dragging(true);
break; break;
case "added": case "added":
List.added_song(msg.value); List.added_song(msg.value);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
if(!w_p) List.dragging(true); if(!w_p) List.dragging(true);
break; break;
case "deleted": case "deleted":
@@ -118,13 +116,17 @@ var List = {
case "vote": case "vote":
if(!offline){ if(!offline){
List.voted_song(msg.value, msg.time); List.voted_song(msg.value, msg.time);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
}
if(!w_p) List.dragging(true); if(!w_p) List.dragging(true);
break; break;
case "song_change": case "song_change":
if(window.location.pathname != "/") List.song_change(msg.time, msg.remove); if(window.location.pathname != "/") List.song_change(msg.time, msg.remove);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
if(!w_p) List.dragging(true); if(!w_p) List.dragging(true);
break; break;
} }