From 2d641d0a8d3ca2a0647932709bb649cf2029af51 Mon Sep 17 00:00:00 2001 From: volumio Date: Sat, 25 Jun 2016 15:01:11 +0000 Subject: [PATCH] fixed search mpd --- app/plugins/music_service/mpd/index.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/app/plugins/music_service/mpd/index.js b/app/plugins/music_service/mpd/index.js index 6629ee762..d75e51b76 100644 --- a/app/plugins/music_service/mpd/index.js +++ b/app/plugins/music_service/mpd/index.js @@ -1230,12 +1230,25 @@ ControllerMpd.prototype.search = function (query) { libQ.all(deferArray).then(function(values){ var list = []; - list=[{type:'title',title:self.commandRouter.getI18nString('COMMON.SEARCH_ARTIST_SECTION')}]. - concat(values[0]). - concat([{type:'title',title:self.commandRouter.getI18nString('COMMON.SEARCH_ALBUM_SECTION')}]). - concat(values[1]). - concat([{type:'title',title:self.commandRouter.getI18nString('COMMON.SEARCH_SONG_SECTION')}]). - concat(values[2]).filter(function(v){return !!(v)==true;}); + if(values[0]) + { + list=[{type:'title',title:self.commandRouter.getI18nString('COMMON.SEARCH_ARTIST_SECTION')}]. + concat(values[0]); + } + + if(values[1]) + { + list=list.concat([{type:'title',title:self.commandRouter.getI18nString('COMMON.SEARCH_ALBUM_SECTION')}]). + concat(values[1]); + } + + if(values[2]) + { + list=list.concat([{type:'title',title:self.commandRouter.getI18nString('COMMON.SEARCH_SONG_SECTION')}]). + concat(values[2]); + } + + list=list.filter(function(v){return !!(v)==true;}) defer.resolve(list); }).fail(function(err){