mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-19 09:43:29 +00:00
eventdb retrieval fix
This commit is contained in:
parent
4c5cc6a20b
commit
b6a70a0085
@ -95,21 +95,21 @@ class EventDB {
|
||||
const query: any = {};
|
||||
|
||||
if (filter.ids) {
|
||||
query.id = { $in: filter.ids };
|
||||
query.id = { $in: filter.ids.map(ID) };
|
||||
} else {
|
||||
if (filter.authors) {
|
||||
query.pubkey = { $in: filter.authors };
|
||||
query.pubkey = { $in: filter.authors.map(ID) };
|
||||
}
|
||||
if (filter.kinds) {
|
||||
query.kind = { $in: filter.kinds };
|
||||
}
|
||||
if (filter['#e']) {
|
||||
// hmm $contains doesn't seem to use binary indexes
|
||||
query.flatTags = { $contains: 'e_' + filter['#e'] };
|
||||
query.flatTags = { $contains: 'e_' + filter['#e'].map(ID) };
|
||||
}
|
||||
if (filter['#p']) {
|
||||
// not indexing for now
|
||||
//query.flatTags = { $contains: 'p_' + filter['#p'] };
|
||||
//query.flatTags = { $contains: 'p_' + filter['#p'].map(ID) };
|
||||
}
|
||||
if (filter.since && filter.until) {
|
||||
query.created_at = { $between: [filter.since, filter.until] };
|
||||
@ -126,9 +126,6 @@ class EventDB {
|
||||
.chain()
|
||||
.find(query)
|
||||
.where((e: Event) => {
|
||||
if (!matchFilter(filter, e)) {
|
||||
return false;
|
||||
}
|
||||
if (filter.keywords && !filter.keywords.some((keyword) => e.content?.includes(keyword))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -94,16 +94,10 @@ const IndexedDB = {
|
||||
async init() {
|
||||
const myPub = Key.getPubKey();
|
||||
|
||||
await db.events.where({ pubkey: myPub }).each(handleEvent);
|
||||
await db.events.where({ pubkey: myPub, kind: 3 }).each(handleEvent); // maybe should be in localstorage?
|
||||
await db.events.where({ pubkey: myPub, kind: 0 }).each(handleEvent);
|
||||
await db.events.where({ kind: 3 }).each(handleEvent);
|
||||
await db.events.where({ kind: 0 }).each(handleEvent);
|
||||
await db.events.where({ kind: 4 }).each(handleEvent);
|
||||
await db.events
|
||||
.orderBy('created_at')
|
||||
.reverse()
|
||||
.filter((event) => event.kind === 1)
|
||||
.limit(INITIAL_EVENT_LOAD_LIMIT)
|
||||
.each(handleEvent);
|
||||
},
|
||||
|
||||
subscribeToAuthors: throttle(async function (this: typeof IndexedDB, limit?: number) {
|
||||
|
Loading…
Reference in New Issue
Block a user