Skip to content

Commit

Permalink
indexeddb unique index fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalmi committed Jan 4, 2024
1 parent f9a5013 commit 2b9e49d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/js/nostr/IndexedDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]",

Check failure on line 26 in src/js/nostr/IndexedDB.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"++id,·pubkey,·kind,·created_at,·[pubkey+kind]"` with `'++id,·pubkey,·kind,·created_at,·[pubkey+kind]'`
tags: "&[type+value+eventId], [type+value], eventId",

Check failure on line 27 in src/js/nostr/IndexedDB.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"&[type+value+eventId],·[type+value],·eventId"` with `'&[type+value+eventId],·[type+value],·eventId'`
});
}
}
Expand Down Expand Up @@ -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('|'));
Expand All @@ -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();
Expand Down

0 comments on commit 2b9e49d

Please sign in to comment.