idb query by all tags
This commit is contained in:
@ -171,29 +171,21 @@ class IndexedDB extends Dexie {
|
|||||||
callback(e);
|
callback(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (filter["#p"] && Array.isArray(filter["#p"])) {
|
let hasTags = false;
|
||||||
for (const eventId of filter["#p"]) {
|
for (const key in filter) {
|
||||||
this.subscribedTags.add("p|" + eventId);
|
if (filter.hasOwnProperty(key) && key.startsWith("#")) {
|
||||||
}
|
hasTags = true;
|
||||||
|
const tagName = key.slice(1); // Remove the hash to get the tag name
|
||||||
await this.getByTags(cb);
|
const values = filter[key];
|
||||||
return;
|
if (Array.isArray(values)) {
|
||||||
}
|
for (const value of values) {
|
||||||
|
this.subscribedTags.add(tagName + "|" + value);
|
||||||
if (filter["#e"] && Array.isArray(filter["#e"])) {
|
}
|
||||||
for (const eventId of filter["#e"]) {
|
}
|
||||||
this.subscribedTags.add("e|" + eventId);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
await this.getByTags(cb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filter["#d"] && Array.isArray(filter["#d"])) {
|
|
||||||
for (const eventId of filter["#d"]) {
|
|
||||||
this.subscribedTags.add("d|" + eventId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasTags) {
|
||||||
await this.getByTags(cb);
|
await this.getByTags(cb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -225,7 +217,6 @@ class IndexedDB extends Dexie {
|
|||||||
const term = filter.search.replace(" sort:popular", "");
|
const term = filter.search.replace(" sort:popular", "");
|
||||||
const regexp = new RegExp(term, "i");
|
const regexp = new RegExp(term, "i");
|
||||||
query = query.filter((event: Event) => event.content?.match(regexp));
|
query = query.filter((event: Event) => event.content?.match(regexp));
|
||||||
filter.limit = filter.limit || 100;
|
|
||||||
}
|
}
|
||||||
if (filter.limit) {
|
if (filter.limit) {
|
||||||
query = query.limit(filter.limit);
|
query = query.limit(filter.limit);
|
||||||
|
Reference in New Issue
Block a user