Improve the precise input element, normalize 'and' to check if it is empty (and to check if no filter is active)

This commit is contained in:
Pieter Vander Vennet 2021-09-08 01:36:44 +02:00
parent 475b89a794
commit a4f4365d71
10 changed files with 262 additions and 28 deletions

View file

@ -5,7 +5,19 @@ export class And extends TagsFilter {
constructor(and: TagsFilter[]) {
super();
this.and = and;
this.and = and
}
normalize(){
const ands = []
for (const c of this.and) {
if(c instanceof And){
ands.push(...c.and)
}else{
ands.push(c)
}
}
return new And(ands)
}
private static combine(filter: string, choices: string[]): string[] {
@ -64,17 +76,6 @@ export class And extends TagsFilter {
return false;
}
for (const selfTag of this.and) {
let matchFound = false;
for (let i = 0; i < other.and.length && !matchFound; i++) {
let otherTag = other.and[i];
matchFound = selfTag.isEquivalent(otherTag);
}
if (!matchFound) {
return false;
}
}
for (const selfTag of this.and) {
let matchFound = false;
for (const otherTag of other.and) {