Browse Source

Fixed issue with error message and bug where songs couldn't be removed from playlists.

KrisVos130 8 years ago
parent
commit
4ddf37f4a7
2 changed files with 14 additions and 6 deletions
  1. 9 2
      backend/logic/actions/playlists.js
  2. 5 4
      frontend/components/Station/Station.vue

+ 9 - 2
backend/logic/actions/playlists.js

@@ -349,13 +349,20 @@ let lib = {
 	 */
 	removeSongFromPlaylist: hooks.loginRequired((session, songId, playlistId, cb, userId) => {
 		async.waterfall([
+			(next) => {
+				if (!songId || typeof songId !== 'string') return next('Invalid song id.');
+				if (!playlistId  || typeof playlistId !== 'string') return next('Invalid playlist id.');
+				next();
+			},
+
 			(next) => {
 				playlists.getPlaylist(playlistId, next);
 			},
 
 			(playlist, next) => {
 				if (!playlist || playlist.createdBy !== userId) return next('Playlist not found');
-				db.models.playlist.update({_id: playlistId}, {$pull: {songs: songId}}, next);
+				console.log(playlist, playlistId, songId);
+				db.models.playlist.update({_id: playlistId}, {$pull: {songs: {_id: songId}}}, next);
 			},
 
 			(res, next) => {
@@ -518,7 +525,7 @@ let lib = {
 	}),
 
 	/**
-	 * Removes a song from a private playlist
+	 * Removes a private playlist
 	 *
 	 * @param {Object} session - the session object automatically added by socket.io
 	 * @param {String} playlistId - the id of the playlist we are moving the song to the top from

+ 5 - 4
frontend/components/Station/Station.vue

@@ -390,11 +390,12 @@
 								if (data.status === 'success') _this.songsList = data.queue;
 							});
 						}
+						if (_this.type === 'official') {
+							_this.socket.emit('stations.getPlaylist', _this.stationId, res => {
+								if (res.status == 'success') _this.songsList = res.data;
+							});
+						}
 					}
-
-					_this.socket.emit('stations.getPlaylist', _this.stationId, res => {
-				 		if (res.status == 'success') _this.songsList = res.data;
-				 	});
 					// UNIX client time before ping
 					let beforePing = Date.now();
 					_this.socket.emit('apis.ping', res => {