mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Check that char.list has any filters before applying hidden block.
This commit is contained in:
@ -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.<string, Function>}
|
||||
|
Reference in New Issue
Block a user