Prechádzať zdrojové kódy

fix(queue songs): if spotify isn't enabled, song can't be added

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 5 rokov pred
rodič
commit
81cb6fa62b

+ 3 - 3
backend/logic/actions/queueSongs.js

@@ -167,9 +167,9 @@ let lib = {
 				});
 			},
 			(newSong, next) => {
-				//TODO Add err object as first param of callback
-				utils.getSongFromSpotify(newSong, (song) => {
-					next(null, song);
+				utils.getSongFromSpotify(newSong, (err, song) => {
+					if (!song) next(null, newSong);
+					else next(err, song);
 				});
 			},
 			(newSong, next) => {

+ 3 - 2
backend/logic/utils.js

@@ -355,7 +355,8 @@ module.exports = {
 		getPage(null, []);
 	},
 	getSongFromSpotify: async (song, cb) => {
-		if (!config.get("apis.spotify.enabled")) return cb(null);
+		if (!config.get("apis.spotify.enabled")) return cb("Spotify is not enabled", null);
+
 		const spotifyParams = [
 			`q=${encodeURIComponent(song.title)}`,
 			`type=track`
@@ -397,7 +398,7 @@ module.exports = {
 				}
 			}
 
-			cb(song);
+			cb(null, song);
 		});
 	},
 	getSongsFromSpotify: async (title, artist, cb) => {

+ 0 - 6
frontend/components/Modals/AddSongToQueue.vue

@@ -206,12 +206,6 @@ export default {
 				_this.$parent.privatePlaylistQueueSelected;
 		});
 	},
-	events: {
-		closeModal: function() {
-			this.$parent.modals.addSongToQueue = !this.$parent.modals
-				.addSongToQueue;
-		}
-	},
 	components: { Modal }
 };
 </script>