Przeglądaj źródła

refactor(Playlists): Updated leftover liked/disliked checks

Owen Diffey 3 lat temu
rodzic
commit
d5de05b884

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

@@ -979,7 +979,7 @@ export default {
 					`Successfully added song "${youtubeId}" to private playlist "${playlistId}" for user "${session.userId}".`
 				);
 
-				if (!isSet && playlist.displayName !== "Liked Songs" && playlist.displayName !== "Disliked Songs") {
+				if (!isSet && playlist.type !== "user-liked" && playlist.type !== "user-disliked") {
 					const songName = newSong.artists
 						? `${newSong.title} by ${newSong.artists.join(", ")}`
 						: newSong.title;

+ 4 - 4
backend/logic/actions/users.js

@@ -273,7 +273,7 @@ export default {
 				},
 
 				next => {
-					playlistModel.findOne({ createdBy: session.userId, displayName: "Liked Songs" }, next);
+					playlistModel.findOne({ createdBy: session.userId, type: "user-liked" }, next);
 				},
 
 				// get all liked songs (as the global rating values for these songs will need adjusted)
@@ -288,7 +288,7 @@ export default {
 				},
 
 				next => {
-					playlistModel.findOne({ createdBy: session.userId, displayName: "Disliked Songs" }, next);
+					playlistModel.findOne({ createdBy: session.userId, type: "user-disliked" }, next);
 				},
 
 				// get all disliked songs (as the global rating values for these songs will need adjusted)
@@ -441,7 +441,7 @@ export default {
 				},
 
 				next => {
-					playlistModel.findOne({ createdBy: userId, displayName: "Liked Songs" }, next);
+					playlistModel.findOne({ createdBy: userId, type: "user-liked" }, next);
 				},
 
 				// get all liked songs (as the global rating values for these songs will need adjusted)
@@ -456,7 +456,7 @@ export default {
 				},
 
 				next => {
-					playlistModel.findOne({ createdBy: userId, displayName: "Disliked Songs" }, next);
+					playlistModel.findOne({ createdBy: userId, type: "user-disliked" }, next);
 				},
 
 				// get all disliked songs (as the global rating values for these songs will need adjusted)

+ 2 - 2
backend/logic/songs.js

@@ -715,7 +715,7 @@ class _SongsModule extends CoreClass {
 				[
 					next => {
 						playlistModel.countDocuments(
-							{ songs: { $elemMatch: { youtubeId: payload.youtubeId } }, displayName: "Liked Songs" },
+							{ songs: { $elemMatch: { youtubeId: payload.youtubeId } }, type: "user-liked" },
 							(err, likes) => {
 								if (err) return next(err);
 								return next(null, likes);
@@ -725,7 +725,7 @@ class _SongsModule extends CoreClass {
 
 					(likes, next) => {
 						playlistModel.countDocuments(
-							{ songs: { $elemMatch: { youtubeId: payload.youtubeId } }, displayName: "Disliked Songs" },
+							{ songs: { $elemMatch: { youtubeId: payload.youtubeId } }, type: "user-disliked" },
 							(err, dislikes) => {
 								if (err) return next(err);
 								return next(err, { likes, dislikes });

+ 2 - 2
frontend/src/components/modals/EditPlaylist/index.vue

@@ -443,12 +443,12 @@ export default {
 			return this.utils.formatTimeLong(length);
 		},
 		removeSongFromPlaylist(id) {
-			if (this.playlist.displayName === "Liked Songs")
+			if (this.playlist.type === "user-liked")
 				return this.socket.dispatch("songs.unlike", id, res => {
 					new Toast(res.message);
 				});
 
-			if (this.playlist.displayName === "Disliked Songs")
+			if (this.playlist.type === "user-disliked")
 				return this.socket.dispatch("songs.undislike", id, res => {
 					new Toast(res.message);
 				});