Browse Source

fix: fixed ImportAlbum import playlist functionality which broke due to changes

Kristian Vos 2 years ago
parent
commit
18dfe350b9
2 changed files with 31 additions and 17 deletions
  1. 3 2
      backend/logic/ws.js
  2. 28 15
      frontend/src/components/modals/ImportAlbum.vue

+ 3 - 2
backend/logic/ws.js

@@ -634,8 +634,9 @@ class _WSModule extends CoreClass {
 
 				if (!namespace) return socket.dispatch("ERROR", "Invalid namespace.");
 				if (!action) return socket.dispatch("ERROR", "Invalid action.");
-				if (!WSModule.actions[namespace]) return socket.dispatch("ERROR", "Namespace not found.");
-				if (!WSModule.actions[namespace][action]) return socket.dispatch("ERROR", "Action not found.");
+				if (!WSModule.actions[namespace]) return socket.dispatch("ERROR", `Namespace ${namespace} not found.`);
+				if (!WSModule.actions[namespace][action])
+					return socket.dispatch("ERROR", `Action ${namespace}.${action} not found.`);
 
 				if (data[data.length - 1].CB_REF) {
 					const { CB_REF, onProgress } = data[data.length - 1];

+ 28 - 15
frontend/src/components/modals/ImportAlbum.vue

@@ -488,26 +488,39 @@ export default {
 			}, 750);
 
 			return this.socket.dispatch(
-				"songs.requestSet",
+				"youtube.requestSet",
 				this.search.playlist.query,
 				false,
 				true,
 				res => {
 					this.isImportingPlaylist = false;
-					const songs = res.songs.filter(song => !song.verified);
-					const songsAlreadyVerified =
-						res.songs.length - songs.length;
-					this.setPlaylistSongs(songs);
-					if (this.discogsAlbum.tracks) {
-						this.trackSongs = this.discogsAlbum.tracks.map(
-							() => []
-						);
-						this.tryToAutoMove();
-					}
-					if (songsAlreadyVerified > 0)
-						new Toast(
-							`${songsAlreadyVerified} songs were already verified, skipping those.`
-						);
+					const youtubeIds = res.videos.map(video => video.youtubeId);
+
+					this.socket.dispatch(
+						"songs.getSongsFromYoutubeIds",
+						youtubeIds,
+						res => {
+							if (res.status === "success") {
+								const songs = res.data.songs.filter(
+									song => !song.verified
+								);
+								const songsAlreadyVerified =
+									res.data.songs.length - songs.length;
+								this.setPlaylistSongs(songs);
+								if (this.discogsAlbum.tracks) {
+									this.trackSongs =
+										this.discogsAlbum.tracks.map(() => []);
+									this.tryToAutoMove();
+								}
+								if (songsAlreadyVerified > 0)
+									new Toast(
+										`${songsAlreadyVerified} songs were already verified, skipping those.`
+									);
+							}
+							new Toast("Could not get songs.");
+						}
+					);
+
 					return new Toast({ content: res.message, timeout: 20000 });
 				}
 			);