@unicitylabs/sphere-sdk 0.6.10-dev.2 → 0.6.10-dev.3

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.
package/dist/index.d.cts CHANGED
@@ -3679,7 +3679,7 @@ declare class GroupChatModule {
3679
3679
  constructor(config?: GroupChatModuleConfig);
3680
3680
  initialize(deps: GroupChatModuleDependencies): void;
3681
3681
  load(): Promise<void>;
3682
- destroy(): void;
3682
+ destroy(): Promise<void>;
3683
3683
  private destroyConnection;
3684
3684
  connect(): Promise<void>;
3685
3685
  getConnectionStatus(): boolean;
package/dist/index.d.ts CHANGED
@@ -3679,7 +3679,7 @@ declare class GroupChatModule {
3679
3679
  constructor(config?: GroupChatModuleConfig);
3680
3680
  initialize(deps: GroupChatModuleDependencies): void;
3681
3681
  load(): Promise<void>;
3682
- destroy(): void;
3682
+ destroy(): Promise<void>;
3683
3683
  private destroyConnection;
3684
3684
  connect(): Promise<void>;
3685
3685
  getConnectionStatus(): boolean;
package/dist/index.js CHANGED
@@ -12381,8 +12381,20 @@ var GroupChatModule = class {
12381
12381
  }
12382
12382
  }
12383
12383
  }
12384
- destroy() {
12384
+ async destroy() {
12385
12385
  this.destroyConnection();
12386
+ if (this.persistTimer) {
12387
+ clearTimeout(this.persistTimer);
12388
+ this.persistTimer = null;
12389
+ }
12390
+ if (this.deps) {
12391
+ try {
12392
+ if (this.persistPromise) await this.persistPromise;
12393
+ await this.doPersistAll();
12394
+ } catch (err) {
12395
+ logger.debug("GroupChat", "Persist on destroy failed", err);
12396
+ }
12397
+ }
12386
12398
  this.groups.clear();
12387
12399
  this.messages.clear();
12388
12400
  this.members.clear();
@@ -12391,10 +12403,7 @@ var GroupChatModule = class {
12391
12403
  this.messageHandlers.clear();
12392
12404
  this.relayAdminPubkeys = null;
12393
12405
  this.relayAdminFetchPromise = null;
12394
- if (this.persistTimer) {
12395
- clearTimeout(this.persistTimer);
12396
- this.persistTimer = null;
12397
- }
12406
+ this.persistPromise = null;
12398
12407
  this.deps = null;
12399
12408
  }
12400
12409
  destroyConnection() {
@@ -12531,16 +12540,14 @@ var GroupChatModule = class {
12531
12540
  this.trackSubscription(
12532
12541
  createNip29Filter({
12533
12542
  kinds: [NIP29_KINDS.GROUP_METADATA, NIP29_KINDS.GROUP_MEMBERS, NIP29_KINDS.GROUP_ADMINS],
12534
- "#d": groupIds,
12535
- ...sinceTimestamp ? { since: sinceTimestamp } : {}
12543
+ "#d": groupIds
12536
12544
  }),
12537
12545
  { onEvent: (event) => this.handleMetadataEvent(event) }
12538
12546
  );
12539
12547
  this.trackSubscription(
12540
12548
  createNip29Filter({
12541
12549
  kinds: [NIP29_KINDS.DELETE_EVENT, NIP29_KINDS.REMOVE_USER, NIP29_KINDS.DELETE_GROUP],
12542
- "#h": groupIds,
12543
- ...sinceTimestamp ? { since: sinceTimestamp } : {}
12550
+ "#h": groupIds
12544
12551
  }),
12545
12552
  { onEvent: (event) => this.handleModerationEvent(event) }
12546
12553
  );
@@ -12559,8 +12566,7 @@ var GroupChatModule = class {
12559
12566
  this.trackSubscription(
12560
12567
  createNip29Filter({
12561
12568
  kinds: [NIP29_KINDS.DELETE_EVENT, NIP29_KINDS.REMOVE_USER, NIP29_KINDS.DELETE_GROUP],
12562
- "#h": [groupId],
12563
- ...sinceTimestamp ? { since: sinceTimestamp } : {}
12569
+ "#h": [groupId]
12564
12570
  }),
12565
12571
  { onEvent: (event) => this.handleModerationEvent(event) }
12566
12572
  );