浏览代码

Hopefully fixed issues with playlists.

KrisVos130 8 年之前
父节点
当前提交
05f7ede1bc
共有 2 个文件被更改,包括 7 次插入6 次删除
  1. 6 6
      backend/logic/actions/playlists.js
  2. 1 0
      backend/logic/playlists.js

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

@@ -426,16 +426,16 @@ let lib = {
 			(playlist, next) => {
 				if (!playlist || playlist.createdBy !== userId) return next('Playlist not found');
 				async.each(playlist.songs, (song, next) => {
-					if (song._id === songId) return next(song);
+					if (song.songId === songId) return next(song);
 					next();
 				}, (err) => {
-					if (err && err._id) return next(null, err);
+					if (err && err.songId) return next(null, err);
 					next('Song not found');
 				});
 			},
 
 			(song, next) => {
-				db.models.playlist.update({_id: playlistId}, {$pull: {songs: {_id: songId}}}, (err) => {
+				db.models.playlist.update({_id: playlistId}, {$pull: {songs: {songId}}}, (err) => {
 					if (err) return next(err);
 					return next(null, song);
 				});
@@ -485,16 +485,16 @@ let lib = {
 			(playlist, next) => {
 				if (!playlist || playlist.createdBy !== userId) return next('Playlist not found');
 				async.each(playlist.songs, (song, next) => {
-					if (song._id === songId) return next(song);
+					if (song.songId === songId) return next(song);
 					next();
 				}, (err) => {
-					if (err && err._id) return next(null, err);
+					if (err && err.songId) return next(null, err);
 					next('Song not found');
 				});
 			},
 
 			(song, next) => {
-				db.models.playlist.update({_id: playlistId}, {$pull: {songs: {_id: songId}}}, (err) => {
+				db.models.playlist.update({_id: playlistId}, {$pull: {songs: {songId}}}, (err) => {
 					if (err) return next(err);
 					return next(null, song);
 				});

+ 1 - 0
backend/logic/playlists.js

@@ -63,6 +63,7 @@ module.exports = {
 			},
 
 			(playlists, next) => {
+				if (!playlists) return next();
 				let playlistIds = Object.keys(playlists);
 				async.each(playlistIds, (playlistId, next) => {
 					db.models.playlist.findOne({_id: playlistId}, (err, playlist) => {