diff --git a/public/script.js b/public/script.js index afab6ab80..b38777951 100644 --- a/public/script.js +++ b/public/script.js @@ -1363,7 +1363,7 @@ async function printCharacters(fullRefresh = false) { } const hidden = (characters.length + groups.length) - displayCount; - if (hidden > 0) { + if (hidden > 0 && entitiesFilter.hasAnyFilter()) { $(listId).append(getHiddenBlock(hidden)); } diff --git a/public/scripts/filters.js b/public/scripts/filters.js index 2743ccdba..ca107fa79 100644 --- a/public/scripts/filters.js +++ b/public/scripts/filters.js @@ -64,6 +64,36 @@ export class FilterHelper { this.onDataChanged = onDataChanged; } + /** + * Checks if the filter data has any values. + * @returns {boolean} Whether the filter data has any values + */ + hasAnyFilter() { + /** + * Checks if the object has any values. + * @param {object} obj The object to check for values + * @returns {boolean} Whether the object has any values + */ + function checkRecursive(obj) { + if (typeof obj === 'string' && obj.length > 0 && obj !== 'UNDEFINED') { + return true; + } else if (typeof obj === 'boolean' && obj) { + return true; + } else if (Array.isArray(obj) && obj.length > 0) { + return true; + } else if (typeof obj === 'object' && obj !== null && Object.keys(obj.length > 0)) { + for (const key in obj) { + if (checkRecursive(obj[key])) { + return true; + } + } + } + return false; + } + + return checkRecursive(this.filterData); + } + /** * The filter functions. * @type {Object.}