Browse Source

feat: added youtubeVideo remove events to EditSongs

Kristian Vos 2 years ago
parent
commit
2bcf34d5f2

+ 10 - 1
backend/logic/actions/songs.js

@@ -278,7 +278,16 @@ export default {
 						"GET_SONGS",
 						{
 							youtubeIds,
-							properties: ["youtubeId", "title", "artists", "thumbnail", "duration", "verified", "_id"]
+							properties: [
+								"youtubeId",
+								"title",
+								"artists",
+								"thumbnail",
+								"duration",
+								"verified",
+								"_id",
+								"youtubeVideoId"
+							]
 						},
 						this
 					)

+ 2 - 1
backend/logic/songs.js

@@ -203,7 +203,8 @@ class _SongsModule extends CoreClass {
 												thumbnail || `https://img.youtube.com/vi/${youtubeId}/mqdefault.jpg`,
 											requestedBy: null,
 											requestedAt: Date.now(),
-											verified: false
+											verified: false,
+											youtubeVideoId: video._id
 										};
 									});
 									next(null, [...songs, ...youtubeVideos]);

+ 5 - 0
backend/logic/youtube.js

@@ -147,6 +147,11 @@ class _YouTubeModule extends CoreClass {
 							room: "admin.youtubeVideos",
 							args: ["event:admin.youtubeVideo.removed", { data: { videoId } }]
 						});
+
+						WSModule.runJob("EMIT_TO_ROOMS", {
+							rooms: ["import-album", "edit-songs"],
+							args: ["event:admin.youtubeVideo.removed", { videoId }]
+						});
 					});
 				}
 			});

+ 11 - 0
frontend/src/components/modals/EditSongs.vue

@@ -305,6 +305,17 @@ export default {
 			},
 			{ modalUuid: this.modalUuid }
 		);
+
+		this.socket.on(
+			`event:admin.youtubeVideo.removed`,
+			res => {
+				const index = this.items
+					.map(item => item.song.youtubeVideoId)
+					.indexOf(res.videoId);
+				if (index !== -1) this.items[index].song.removed = true;
+			},
+			{ modalUuid: this.modalUuid }
+		);
 	},
 	beforeUnmount() {
 		this.socket.dispatch("apis.leaveRoom", "edit-songs");