Various
This commit is contained in:
@ -6,19 +6,8 @@ import { ReqFilter } from "nostr";
|
||||
export function trimFilters(filters: Array<ReqFilter>) {
|
||||
const fNew = [];
|
||||
for (const f of filters) {
|
||||
let arrays = 0;
|
||||
for (const [k, v] of Object.entries(f)) {
|
||||
if (Array.isArray(v)) {
|
||||
arrays++;
|
||||
if (v.length === 0) {
|
||||
delete f[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arrays > 0 && Object.entries(f).some(v => Array.isArray(v))) {
|
||||
fNew.push(f);
|
||||
} else if (arrays === 0) {
|
||||
const ent = Object.entries(f).filter(([,v]) => Array.isArray(v));
|
||||
if(ent.every(([,v]) => (v as Array<string | number>).length > 0)) {
|
||||
fNew.push(f);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user