@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.
@@ -3269,7 +3269,7 @@ declare class GroupChatModule {
3269
3269
  constructor(config?: GroupChatModuleConfig);
3270
3270
  initialize(deps: GroupChatModuleDependencies): void;
3271
3271
  load(): Promise<void>;
3272
- destroy(): void;
3272
+ destroy(): Promise<void>;
3273
3273
  private destroyConnection;
3274
3274
  connect(): Promise<void>;
3275
3275
  getConnectionStatus(): boolean;
@@ -3269,7 +3269,7 @@ declare class GroupChatModule {
3269
3269
  constructor(config?: GroupChatModuleConfig);
3270
3270
  initialize(deps: GroupChatModuleDependencies): void;
3271
3271
  load(): Promise<void>;
3272
- destroy(): void;
3272
+ destroy(): Promise<void>;
3273
3273
  private destroyConnection;
3274
3274
  connect(): Promise<void>;
3275
3275
  getConnectionStatus(): boolean;
@@ -12112,8 +12112,20 @@ var GroupChatModule = class {
12112
12112
  }
12113
12113
  }
12114
12114
  }
12115
- destroy() {
12115
+ async destroy() {
12116
12116
  this.destroyConnection();
12117
+ if (this.persistTimer) {
12118
+ clearTimeout(this.persistTimer);
12119
+ this.persistTimer = null;
12120
+ }
12121
+ if (this.deps) {
12122
+ try {
12123
+ if (this.persistPromise) await this.persistPromise;
12124
+ await this.doPersistAll();
12125
+ } catch (err) {
12126
+ logger.debug("GroupChat", "Persist on destroy failed", err);
12127
+ }
12128
+ }
12117
12129
  this.groups.clear();
12118
12130
  this.messages.clear();
12119
12131
  this.members.clear();
@@ -12122,10 +12134,7 @@ var GroupChatModule = class {
12122
12134
  this.messageHandlers.clear();
12123
12135
  this.relayAdminPubkeys = null;
12124
12136
  this.relayAdminFetchPromise = null;
12125
- if (this.persistTimer) {
12126
- clearTimeout(this.persistTimer);
12127
- this.persistTimer = null;
12128
- }
12137
+ this.persistPromise = null;
12129
12138
  this.deps = null;
12130
12139
  }
12131
12140
  destroyConnection() {
@@ -12262,16 +12271,14 @@ var GroupChatModule = class {
12262
12271
  this.trackSubscription(
12263
12272
  createNip29Filter({
12264
12273
  kinds: [NIP29_KINDS.GROUP_METADATA, NIP29_KINDS.GROUP_MEMBERS, NIP29_KINDS.GROUP_ADMINS],
12265
- "#d": groupIds,
12266
- ...sinceTimestamp ? { since: sinceTimestamp } : {}
12274
+ "#d": groupIds
12267
12275
  }),
12268
12276
  { onEvent: (event) => this.handleMetadataEvent(event) }
12269
12277
  );
12270
12278
  this.trackSubscription(
12271
12279
  createNip29Filter({
12272
12280
  kinds: [NIP29_KINDS.DELETE_EVENT, NIP29_KINDS.REMOVE_USER, NIP29_KINDS.DELETE_GROUP],
12273
- "#h": groupIds,
12274
- ...sinceTimestamp ? { since: sinceTimestamp } : {}
12281
+ "#h": groupIds
12275
12282
  }),
12276
12283
  { onEvent: (event) => this.handleModerationEvent(event) }
12277
12284
  );
@@ -12290,8 +12297,7 @@ var GroupChatModule = class {
12290
12297
  this.trackSubscription(
12291
12298
  createNip29Filter({
12292
12299
  kinds: [NIP29_KINDS.DELETE_EVENT, NIP29_KINDS.REMOVE_USER, NIP29_KINDS.DELETE_GROUP],
12293
- "#h": [groupId],
12294
- ...sinceTimestamp ? { since: sinceTimestamp } : {}
12300
+ "#h": [groupId]
12295
12301
  }),
12296
12302
  { onEvent: (event) => this.handleModerationEvent(event) }
12297
12303
  );