From de7a8067cb60dde79ad0ef4c2077b81c2dfc2ef9 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 12 Apr 2018 14:28:20 +0200 Subject: [PATCH] Better filtering of music results --- platypush/backend/http/static/js/music.mpd.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/platypush/backend/http/static/js/music.mpd.js b/platypush/backend/http/static/js/music.mpd.js index f2c4259610..38de65f316 100644 --- a/platypush/backend/http/static/js/music.mpd.js +++ b/platypush/backend/http/static/js/music.mpd.js @@ -713,15 +713,18 @@ $(document).ready(function() { if (Object.keys(searchFilters).length > 1) { results = results.filter(function(item) { return ( - ('title' in searchFilters && 'title' in item - ? item.title.toLowerCase().indexOf( - searchFilters.title.toLowerCase()) >= 0 : true) && - ('album' in searchFilters && 'album' in item - ? item.album.toLowerCase().indexOf( - searchFilters.album.toLowerCase()) >= 0 : true) && - ('albumartist' in searchFilters && 'artist' in item - ? item.artist.toLowerCase().indexOf( - searchFilters.albumartist.toLowerCase()) >= 0 : true) + ('title' in searchFilters + ? (item.title || '').toLowerCase().indexOf( + searchFilters.title.toLowerCase()) >= 0 + : true) && + ('album' in searchFilters + ? (item.album || '').toLowerCase().indexOf( + searchFilters.album.toLowerCase()) >= 0 + : true) && + ('albumartist' in searchFilters + ? (item.artist || '').toLowerCase().indexOf( + searchFilters.albumartist.toLowerCase()) >= 0 + : true) ); }); }