Browse Source

Fixed messed up last commit, and improved performance due to looping through all songs every station skip

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

+ 1 - 1
backend/logic/actions/playlists.js

@@ -631,7 +631,7 @@ export default {
 				(playlist, next) => {
 					if (!playlist.isUserModifiable) return next("Playlist cannot be shuffled.");
 
-					return UtilsModule.runJob("SHUFFLE", { array: playlist.songs }, this)
+					return UtilsModule.runJob("SHUFFLE_SONG_POSITIONS", { array: playlist.songs }, this)
 						.then(result => next(null, result.array))
 						.catch(next);
 				},

+ 6 - 3
backend/logic/stations.js

@@ -480,7 +480,7 @@ class _StationsModule extends CoreClass {
 					},
 
 					(playlist, next) => {
-						UtilsModule.runJob("SHUFFLE_SONG_POSITIONS", { array: playlist.songs }, this)
+						UtilsModule.runJob("SHUFFLE", { array: playlist.songs }, this)
 							.then(response => {
 								next(null, response.array);
 							})
@@ -502,12 +502,15 @@ class _StationsModule extends CoreClass {
 						const songsToAdd = [];
 						playlistSongs
 							.map(song => song._doc)
-							.forEach(song => {
+							.every(song => {
 								if (
 									songsToAdd.length < songsStillNeeded &&
 									currentSongIds.indexOf(song._id.toString()) === -1
-								)
+								) {
 									songsToAdd.push(song);
+									return false;
+								}
+								return true;
 							});
 
 						next(null, [...currentSongs, ...songsToAdd]);