refactor: useRequestBuilder

This commit is contained in:
2024-09-12 16:26:30 +01:00
parent 9eb97701b4
commit e877625923
28 changed files with 195 additions and 205 deletions

View File

@ -56,7 +56,9 @@ export class QueryManager extends EventEmitter<QueryManagerEvents> {
});
this.#queries.set(req.id, q);
this.emit("change");
if (req.numFilters > 0) {
this.emit("change");
}
return q;
}
}

View File

@ -181,10 +181,13 @@ export class Query extends EventEmitter<QueryEvents> {
* Adds another request to this one
*/
addRequest(req: RequestBuilder) {
this.#log("Add query %O to %s", req, this.id);
this.requests.push(...req.buildRaw());
this.#start();
return true;
if (req.numFilters > 0) {
this.#log("Add query %O to %s", req, this.id);
this.requests.push(...req.buildRaw());
this.#start();
return true;
}
return false;
}
isOpen() {
@ -326,7 +329,9 @@ export class Query extends EventEmitter<QueryEvents> {
if (this.#replaceable) {
rawFilters.push(...this.filters);
}
this.emit("request", this.id, rawFilters);
if (rawFilters.length > 0) {
this.emit("request", this.id, rawFilters);
}
}
#stopCheckTraces() {

View File

@ -72,6 +72,11 @@ export class RequestBuilder {
return this.#options;
}
clear() {
this.#builders = [];
this.#options = undefined;
}
/**
* Add another request builders filters to this one
*/