mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-16 16:23: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() {
|
constructor() {
|
||||||
super('iris');
|
super('iris');
|
||||||
|
|
||||||
this.version(5).stores({
|
this.version(6).stores({
|
||||||
events: 'id, pubkey, kind, created_at, [pubkey+kind]',
|
// TODO use events multientry index for *tags
|
||||||
tags: 'id, eventId, [type+value]',
|
events: "++id, pubkey, kind, created_at, [pubkey+kind]",
|
||||||
|
tags: "&[type+value+eventId], [type+value], eventId",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,13 +120,13 @@ const IndexedDB = {
|
|||||||
.anyOf(authors)
|
.anyOf(authors)
|
||||||
.limit(limit || 1000)
|
.limit(limit || 1000)
|
||||||
.each(handleEvent);
|
.each(handleEvent);
|
||||||
}, 1000),
|
}, 100),
|
||||||
|
|
||||||
subscribeToEventIds: throttle(async function (this: typeof IndexedDB) {
|
subscribeToEventIds: throttle(async function (this: typeof IndexedDB) {
|
||||||
const ids = [...this.subscribedEventIds];
|
const ids = [...this.subscribedEventIds];
|
||||||
this.subscribedEventIds.clear();
|
this.subscribedEventIds.clear();
|
||||||
await db.events.where('id').anyOf(ids).each(handleEvent);
|
await db.events.where('id').anyOf(ids).each(handleEvent);
|
||||||
}, 1000),
|
}, 100),
|
||||||
|
|
||||||
subscribeToTags: throttle(async function (this: typeof IndexedDB) {
|
subscribeToTags: throttle(async function (this: typeof IndexedDB) {
|
||||||
const tagPairs = [...this.subscribedTags].map((tag) => tag.split('|'));
|
const tagPairs = [...this.subscribedTags].map((tag) => tag.split('|'));
|
||||||
@ -136,7 +137,7 @@ const IndexedDB = {
|
|||||||
.each((tag) => this.subscribedEventIds.add(tag.eventId));
|
.each((tag) => this.subscribedEventIds.add(tag.eventId));
|
||||||
|
|
||||||
await this.subscribeToEventIds();
|
await this.subscribeToEventIds();
|
||||||
}, 1000),
|
}, 100),
|
||||||
|
|
||||||
async countEvents() {
|
async countEvents() {
|
||||||
return await db.events.count();
|
return await db.events.count();
|
||||||
|
Loading…
Reference in New Issue
Block a user