Browse Source

Various bug fixes

Kristian Vos 3 years ago
parent
commit
3a074833df

+ 4 - 3
backend/logic/songs.js

@@ -934,15 +934,16 @@ class _SongsModule extends CoreClass {
 						status
 					};
 
+					if (err && err === "This song is already in the database.") return reject(new ErrorWithData(err, { song: trimmedSong }));
+					
 					SongsModule.runJob("UPDATE_SONG", { songId: song._id });
 
 					CacheModule.runJob("PUB", {
 						channel: "song.newUnverifiedSong",
 						value: song._id
 					});
-
-					if (err && err === "This song is already in the database.") return reject(new ErrorWithData(err, { song: trimmedSong }));
-					else return resolve({ song: trimmedSong });
+					
+					return resolve({ song: trimmedSong });
 				}
 			);
 		});

+ 10 - 31
frontend/src/components/modals/EditSong.vue

@@ -874,7 +874,9 @@ export default {
 		this.socket.on(
 			"event:admin.hiddenSong.created",
 			res => {
-				this.song.status = res.data.song.status;
+				if (res.data.songId === this.song._id) {
+					this.song.status = res.data.song.status;
+				}
 			},
 			{ modal: "editSong" }
 		);
@@ -882,7 +884,9 @@ export default {
 		this.socket.on(
 			"event:admin.unverifiedSong.created",
 			res => {
-				this.song.status = res.data.song.status;
+				if (res.data.songId === this.song._id) {
+					this.song.status = res.data.song.status;
+				}
 			},
 			{ modal: "editSong" }
 		);
@@ -890,38 +894,12 @@ export default {
 		this.socket.on(
 			"event:admin.verifiedSong.created",
 			res => {
-				this.song.status = res.data.song.status;
-			},
-			{ modal: "editSong" }
-		);
-
-		this.socket.on(
-			"event:admin.hiddenSong.deleted",
-			() => {
-				new Toast("The song you were editing was removed");
-				this.closeModal("editSong");
-			},
-			{ modal: "editSong" }
-		);
-
-		this.socket.on(
-			"event:admin.unverifiedSong.deleted",
-			() => {
-				new Toast("The song you were editing was removed");
-				this.closeModal("editSong");
-			},
-			{ modal: "editSong" }
-		);
-
-		this.socket.on(
-			"event:admin.verifiedSong.deleted",
-			() => {
-				new Toast("The song you were editing was removed");
-				this.closeModal("editSong");
+				if (res.data.songId === this.song._id) {
+					this.song.status = res.data.song.status;
+				}
 			},
 			{ modal: "editSong" }
 		);
-
 		keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
 			keyCode: 101,
 			preventDefault: true,
@@ -1083,6 +1061,7 @@ export default {
 		*/
 	},
 	beforeDestroy() {
+		this.video.player.stopVideo();
 		this.playerReady = false;
 		clearInterval(this.interval);
 		clearInterval(this.activityWatchVideoDataInterval);

+ 3 - 3
frontend/src/components/modals/ImportAlbum.vue

@@ -265,7 +265,7 @@
 						<!-- <transition-group> -->
 						<song-item
 							v-for="song in playlistSongs"
-							:key="song._id"
+							:key="`playlist-song-${song._id}`"
 							:song="song"
 						>
 						</song-item>
@@ -296,7 +296,7 @@
 							<!-- <transition-group> -->
 							<song-item
 								v-for="song in trackSongs[index]"
-								:key="song._id"
+								:key="`track-song-${song._id}`"
 								:song="song"
 							>
 							</song-item>
@@ -462,7 +462,7 @@ export default {
 					const songsAlreadyVerified =
 						res.songs.length - songs.length;
 					this.setPlaylistSongs(songs);
-					this.trackSongs = songs.map(() => []);
+					this.trackSongs = this.discogsAlbum.tracks.map(() => []);
 					this.tryToAutoMove();
 					if (songsAlreadyVerified > 0)
 						new Toast(

+ 1 - 7
frontend/src/pages/Admin/tabs/HiddenSongs.vue

@@ -215,12 +215,6 @@ export default {
 			socket: "websockets/getSocket"
 		})
 	},
-	watch: {
-		// eslint-disable-next-line func-names
-		"modals.editSong": function(value) {
-			if (value === false) this.stopVideo();
-		}
-	},
 	mounted() {
 		this.socket.on("event:admin.hiddenSong.created", res => {
 			this.addSong(res.data.song);
@@ -307,7 +301,7 @@ export default {
 			"removeSong",
 			"updateSong"
 		]),
-		...mapActions("modals/editSong", ["editSong", "stopVideo"]),
+		...mapActions("modals/editSong", ["editSong"]),
 		...mapActions("modalVisibility", ["openModal"])
 	}
 };

+ 1 - 7
frontend/src/pages/Admin/tabs/UnverifiedSongs.vue

@@ -228,12 +228,6 @@ export default {
 			socket: "websockets/getSocket"
 		})
 	},
-	watch: {
-		// eslint-disable-next-line func-names
-		"modals.editSong": function(value) {
-			if (value === false) this.stopVideo();
-		}
-	},
 	mounted() {
 		this.socket.on("event:admin.unverifiedSong.created", res => {
 			this.addSong(res.data.song);
@@ -328,7 +322,7 @@ export default {
 			"removeSong",
 			"updateSong"
 		]),
-		...mapActions("modals/editSong", ["editSong", "stopVideo"]),
+		...mapActions("modals/editSong", ["editSong"]),
 		...mapActions("modalVisibility", ["openModal"])
 	}
 };

+ 1 - 7
frontend/src/pages/Admin/tabs/VerifiedSongs.vue

@@ -324,12 +324,6 @@ export default {
 			socket: "websockets/getSocket"
 		})
 	},
-	watch: {
-		// eslint-disable-next-line func-names
-		"modals.editSong": function(val) {
-			if (!val) this.stopVideo();
-		}
-	},
 	mounted() {
 		this.socket.on("event:admin.verifiedSong.created", res => {
 			this.addSong(res.data.song);
@@ -444,7 +438,7 @@ export default {
 			"removeSong",
 			"updateSong"
 		]),
-		...mapActions("modals/editSong", ["editSong", "stopVideo"]),
+		...mapActions("modals/editSong", ["editSong"]),
 		...mapActions("modalVisibility", ["openModal", "closeModal"])
 	}
 };