|
@@ -584,6 +584,7 @@ class _PlaylistsModule extends CoreClass {
|
|
*/
|
|
*/
|
|
AUTOFILL_STATION_PLAYLIST(payload) {
|
|
AUTOFILL_STATION_PLAYLIST(payload) {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
|
+ let originalPlaylist = null;
|
|
async.waterfall(
|
|
async.waterfall(
|
|
[
|
|
[
|
|
next => {
|
|
next => {
|
|
@@ -601,7 +602,8 @@ class _PlaylistsModule extends CoreClass {
|
|
|
|
|
|
(station, next) => {
|
|
(station, next) => {
|
|
PlaylistsModule.runJob("GET_PLAYLIST", { playlistId: station.playlist2 }, this)
|
|
PlaylistsModule.runJob("GET_PLAYLIST", { playlistId: station.playlist2 }, this)
|
|
- .then(() => {
|
|
|
|
|
|
+ .then(playlist => {
|
|
|
|
+ originalPlaylist = playlist;
|
|
next(null, station);
|
|
next(null, station);
|
|
})
|
|
})
|
|
.catch(err => {
|
|
.catch(err => {
|
|
@@ -671,8 +673,16 @@ class _PlaylistsModule extends CoreClass {
|
|
PlaylistsModule.playlistModel.updateOne(
|
|
PlaylistsModule.playlistModel.updateOne(
|
|
{ _id: station.playlist2 },
|
|
{ _id: station.playlist2 },
|
|
{ $set: { songs: includedSongs } },
|
|
{ $set: { songs: includedSongs } },
|
|
- next
|
|
|
|
|
|
+ err => {
|
|
|
|
+ next(err, includedSongs);
|
|
|
|
+ }
|
|
);
|
|
);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ (includedSongs, next) => {
|
|
|
|
+ if (originalPlaylist.songs.length === 0 && includedSongs.length > 0)
|
|
|
|
+ StationsModule.runJob("SKIP_STATION", { stationId: payload.stationId });
|
|
|
|
+ next();
|
|
}
|
|
}
|
|
],
|
|
],
|
|
err => {
|
|
err => {
|