Browse Source

Fixed bugs from last commit and improved deleting orphaned station playlists

Kristian Vos 4 years ago
parent
commit
4d3787651a
2 changed files with 9 additions and 3 deletions
  1. 7 1
      backend/logic/playlists.js
  2. 2 2
      backend/logic/stations.js

+ 7 - 1
backend/logic/playlists.js

@@ -426,7 +426,13 @@ class _PlaylistsModule extends CoreClass {
 						1,
 						(playlist, next) => {
 							StationsModule.runJob("GET_STATION", { stationId: playlist.createdFor }, this)
-								.then(() => {
+								.then(station => {
+									console.log(111);
+									console.dir(station.playlist2);
+									console.dir(playlist._id);
+									if (station.playlist2 !== playlist._id.toString()) {
+										orphanedPlaylists.push(playlist);
+									}
 									next();
 								})
 								.catch(err => {

+ 2 - 2
backend/logic/stations.js

@@ -570,7 +570,7 @@ class _StationsModule extends CoreClass {
 					},
 
 					(station, next) => {
-						if (station.playlist.length === 0) next(true, "No songs available.");
+						if (station.playlist.length === 0) next("No songs available.");
 						else {
 							next(null, station.playlist[0]);
 						}
@@ -795,7 +795,7 @@ class _StationsModule extends CoreClass {
 													next(null, response.song, 0, station);
 												})
 												.catch(err => {
-													if (err === "No songs available") next(null, null, 0, station);
+													if (err === "No songs available.") next(null, null, 0, station);
 													else next(err);
 												});
 										})