From 740cf021f897ac40199f057cd9a392536743bdad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Sat, 3 Mar 2018 12:12:32 +0100 Subject: [PATCH] Fixed issue with correct title not returning result --- server/handlers/search.js | 16 ++++++++++++---- server/routing/client/api.js | 1 - 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/server/handlers/search.js b/server/handlers/search.js index 3b1503e4..de04e783 100644 --- a/server/handlers/search.js +++ b/server/handlers/search.js @@ -45,15 +45,23 @@ function get_correct_info(song_generated, channel, broadcast, callback) { io.to(channel).emit("channel", {type: "changed_values", value: song_generated}); } } else { - callback(song_generated, true); + if(typeof(callback) == "function") { + callback(song_generated, true); + } } }); + } else { + if(typeof(callback) == "function") { + callback(song_generated, true); + } } } else { findSimilar(song_generated, channel, broadcast, callback) } } catch(e){ - callback({}, false); + if(typeof(callback) == "function") { + callback({}, false); + } } }); } @@ -123,7 +131,7 @@ function findSimilar(msg, channel, broadcast, callback) { io.to(channel).emit("channel", {type: "changed_values", value: element}); } } - if(callback) { + if(typeof(callback) == "function") { msg.title = element.title; msg.id = element.id; msg.duration = element.duration; @@ -132,7 +140,7 @@ function findSimilar(msg, channel, broadcast, callback) { callback(msg, true); } }); - } else if(callback) { + } else if(typeof(callback) == "function") { callback({}, false); } }); diff --git a/server/routing/client/api.js b/server/routing/client/api.js index af6240e3..54362448 100644 --- a/server/routing/client/api.js +++ b/server/routing/client/api.js @@ -381,7 +381,6 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.header({"Content-Type": "application/json"}); - var fetch_only = false; if(req.body.hasOwnProperty('fetch_song')) { fetch_only = true;