mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-07 20:13:28 +00:00
indexeddb unique index fix
This commit is contained in:
parent
452456927a
commit
a522e919c6
@ -21,9 +21,10 @@ class MyDexie extends Dexie {
|
||||
constructor() {
|
||||
super('iris');
|
||||
|
||||
this.version(5).stores({
|
||||
events: 'id, pubkey, kind, created_at, [pubkey+kind]',
|
||||
tags: 'id, eventId, [type+value]',
|
||||
this.version(6).stores({
|
||||
// TODO use events multientry index for *tags
|
||||
events: "++id, pubkey, kind, created_at, [pubkey+kind]",
|
||||
tags: "&[type+value+eventId], [type+value], eventId",
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -119,13 +120,13 @@ const IndexedDB = {
|
||||
.anyOf(authors)
|
||||
.limit(limit || 1000)
|
||||
.each(handleEvent);
|
||||
}, 1000),
|
||||
}, 100),
|
||||
|
||||
subscribeToEventIds: throttle(async function (this: typeof IndexedDB) {
|
||||
const ids = [...this.subscribedEventIds];
|
||||
this.subscribedEventIds.clear();
|
||||
await db.events.where('id').anyOf(ids).each(handleEvent);
|
||||
}, 1000),
|
||||
}, 100),
|
||||
|
||||
subscribeToTags: throttle(async function (this: typeof IndexedDB) {
|
||||
const tagPairs = [...this.subscribedTags].map((tag) => tag.split('|'));
|
||||
@ -136,7 +137,7 @@ const IndexedDB = {
|
||||
.each((tag) => this.subscribedEventIds.add(tag.eventId));
|
||||
|
||||
await this.subscribeToEventIds();
|
||||
}, 1000),
|
||||
}, 100),
|
||||
|
||||
async countEvents() {
|
||||
return await db.events.count();
|
||||
|
Loading…
Reference in New Issue
Block a user