Ver Fonte

fix: some song like/dislike/playlist actions would add false-positive activity items

Kristian Vos há 2 anos atrás
pai
commit
4f4f233b4d
2 ficheiros alterados com 9 adições e 7 exclusões
  1. 5 3
      backend/logic/actions/playlists.js
  2. 4 4
      backend/logic/actions/songs.js

+ 5 - 3
backend/logic/actions/playlists.js

@@ -1514,9 +1514,11 @@ export default {
 
 				// update cache representation of the playlist
 				(res, next) => {
-					PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId }, this)
-						.then(playlist => next(null, playlist))
-						.catch(next);
+					if (res.modifiedCount === 1)
+						PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId }, this)
+							.then(playlist => next(null, playlist))
+							.catch(next);
+					else next("Song wasn't in playlist.");
 				},
 
 				(playlist, next) => {

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

@@ -1271,7 +1271,7 @@ export default {
 							this
 						)
 						.then(res => {
-							if (res.status === "error")
+							if (res.status === "error" && res.message !== "Song wasn't in playlist.")
 								return next("Unable to remove song from the 'Disliked Songs' playlist.");
 							return next(null, song, user.likedSongsPlaylist);
 						})
@@ -1389,7 +1389,7 @@ export default {
 							this
 						)
 						.then(res => {
-							if (res.status === "error")
+							if (res.status === "error" && res.message !== "Song wasn't in playlist.")
 								return next("Unable to remove song from the 'Liked Songs' playlist.");
 							return next(null, song, user.dislikedSongsPlaylist);
 						})
@@ -1527,7 +1527,7 @@ export default {
 							this
 						)
 						.then(res => {
-							if (res.status === "error")
+							if (res.status === "error" && res.message !== "Song wasn't in playlist.")
 								return next("Unable to remove song from the 'Liked Songs' playlist.");
 							return next(null, song);
 						})
@@ -1624,7 +1624,7 @@ export default {
 							this
 						)
 						.then(res => {
-							if (res.status === "error")
+							if (res.status === "error" && res.message !== "Song wasn't in playlist.")
 								return next("Unable to remove song from the 'Disliked Songs' playlist.");
 							return next(null, song, user.likedSongsPlaylist);
 						})