nostr-idb 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,8 @@ import { getEventsForFilters, countEventsForFilters, } from "../database/query-f
5
5
  import { sortByDate } from "../utils.js";
6
6
  import { nanoid } from "../lib/nanoid.js";
7
7
  import { logger } from "../debug.js";
8
- import { getEventUID, pruneLastUsed } from "../index.js";
8
+ import { getEventUID } from "../database/ingest.js";
9
+ import { pruneLastUsed } from "../database/prune.js";
9
10
  const defaultOptions = {
10
11
  batchWrite: 1000,
11
12
  writeInterval: 100,
@@ -125,7 +126,11 @@ export class RelayCore {
125
126
  return sub;
126
127
  }
127
128
  unsubscribe(id) {
128
- log(`Closing ${id}`);
129
- this.subscriptions.delete(id);
129
+ const sub = this.subscriptions.get(id);
130
+ if (sub) {
131
+ log(`Closing ${id}`);
132
+ sub.onclose?.("unsubscribe");
133
+ this.subscriptions.delete(id);
134
+ }
130
135
  }
131
136
  }
@@ -7486,8 +7486,12 @@ class RelayCore {
7486
7486
  return sub;
7487
7487
  }
7488
7488
  unsubscribe(id) {
7489
- log$1(`Closing ${id}`);
7490
- this.subscriptions.delete(id);
7489
+ const sub = this.subscriptions.get(id);
7490
+ if (sub) {
7491
+ log$1(`Closing ${id}`);
7492
+ sub.onclose?.("unsubscribe");
7493
+ this.subscriptions.delete(id);
7494
+ }
7491
7495
  }
7492
7496
  }
7493
7497
 
@@ -7486,8 +7486,12 @@ class RelayCore {
7486
7486
  return sub;
7487
7487
  }
7488
7488
  unsubscribe(id) {
7489
- log$1(`Closing ${id}`);
7490
- this.subscriptions.delete(id);
7489
+ const sub = this.subscriptions.get(id);
7490
+ if (sub) {
7491
+ log$1(`Closing ${id}`);
7492
+ sub.onclose?.("unsubscribe");
7493
+ this.subscriptions.delete(id);
7494
+ }
7491
7495
  }
7492
7496
  }
7493
7497
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nostr-idb",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "A collection of helper methods for storing nostr events in IndexedDB",
5
5
  "author": "hzrd149",
6
6
  "license": "MIT",