From 45f1dc1e20c0e062bac7402e75436da7e2f13b9e Mon Sep 17 00:00:00 2001 From: jcorporation Date: Mon, 17 Sep 2018 16:54:59 +0100 Subject: [PATCH] Fix: filter empty tag values in browse database --- htdocs/js/mympd.js | 5 ----- src/mpd_client.c | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/js/mympd.js b/htdocs/js/mympd.js index fe4a814..a224c29 100644 --- a/htdocs/js/mympd.js +++ b/htdocs/js/mympd.js @@ -1234,8 +1234,6 @@ function parseListDBtags(obj) { document.getElementById('btnBrowseDatabaseTag').innerHTML = '« ' + app.current.view; document.getElementById('BrowseDatabaseAlbumListCaption').innerText = obj.searchtagtype + ': ' + obj.searchstr; var nrItems = obj.data.length; - if (nrItems == 1 && obj.data[0].value == '') - nrItems = 0; var cardContainer = document.getElementById('BrowseDatabaseAlbumList'); var cards = cardContainer.getElementsByClassName('col-md'); for (var i = 0; i < nrItems; i++) { @@ -1277,12 +1275,9 @@ function parseListDBtags(obj) { document.getElementById('BrowseDatabaseAddAllSongs').parentNode.parentNode.classList.add('hide'); document.getElementById('btnBrowseDatabaseTag').parentNode.classList.add('hide'); - if (obj.data[0] && obj.data[0].value == '') - obj.data.shift(); var nrItems = obj.data.length; var tbody = document.getElementById(app.current.app + app.current.tab + 'TagList').getElementsByTagName('tbody')[0]; var tr = tbody.getElementsByTagName('tr'); - var skipped = 0; for (var i = 0; i < nrItems; i++) { var uri = encodeURI(obj.data[i].value); if (tr[i]) diff --git a/src/mpd_client.c b/src/mpd_client.c index 7483b47..267f341 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -1389,7 +1389,10 @@ int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char * while((pair = mpd_recv_pair_tag(mpd.conn, mpd_tag_name_parse(mpdtagtype))) != NULL) { entity_count ++; if (entity_count > offset && entity_count <= offset + MAX_ELEMENTS_PER_PAGE) { - if (strncmp(filter, "-", 1) == 0 || strncasecmp(filter, pair->value, 1) == 0 || + if (strcmp(pair->value, "") == 0) { + entity_count --; + } + else if (strncmp(filter, "-", 1) == 0 || strncasecmp(filter, pair->value, 1) == 0 || (strncmp(filter, "0", 1) == 0 && isalpha(*pair->value) == 0 ) ) { if (entities_returned ++)