@unicitylabs/sphere-sdk 0.6.10-dev.5 → 0.6.10-dev.6

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.
@@ -12630,47 +12630,24 @@ var GroupChatModule = class {
12630
12630
  await this.ensureConnected();
12631
12631
  if (!this.client) return [];
12632
12632
  const groupsMap = /* @__PURE__ */ new Map();
12633
- const memberCountsMap = /* @__PURE__ */ new Map();
12634
- await Promise.all([
12635
- this.oneshotSubscription(
12636
- new import_nostr_js_sdk4.Filter({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
12637
- {
12638
- onEvent: (event) => {
12639
- const group = this.parseGroupMetadata(event);
12640
- if (group && group.visibility === GroupVisibility.PUBLIC) {
12641
- const existing = groupsMap.get(group.id);
12642
- if (!existing || group.createdAt > existing.createdAt) {
12643
- groupsMap.set(group.id, group);
12644
- }
12645
- }
12646
- },
12647
- onComplete: () => {
12648
- },
12649
- timeoutMs: 1e4,
12650
- timeoutLabel: "fetchAvailableGroups(metadata)"
12651
- }
12652
- ),
12653
- this.oneshotSubscription(
12654
- new import_nostr_js_sdk4.Filter({ kinds: [NIP29_KINDS.GROUP_MEMBERS] }),
12655
- {
12656
- onEvent: (event) => {
12657
- const groupId = this.getGroupIdFromMetadataEvent(event);
12658
- if (groupId) {
12659
- const pTags = event.tags.filter((t) => t[0] === "p");
12660
- memberCountsMap.set(groupId, pTags.length);
12633
+ await this.oneshotSubscription(
12634
+ new import_nostr_js_sdk4.Filter({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
12635
+ {
12636
+ onEvent: (event) => {
12637
+ const group = this.parseGroupMetadata(event);
12638
+ if (group && group.visibility === GroupVisibility.PUBLIC) {
12639
+ const existing = groupsMap.get(group.id);
12640
+ if (!existing || group.createdAt > existing.createdAt) {
12641
+ groupsMap.set(group.id, group);
12661
12642
  }
12662
- },
12663
- onComplete: () => {
12664
- },
12665
- timeoutMs: 1e4,
12666
- timeoutLabel: "fetchAvailableGroups(members)"
12667
- }
12668
- )
12669
- ]);
12670
- for (const [groupId, count] of memberCountsMap) {
12671
- const group = groupsMap.get(groupId);
12672
- if (group) group.memberCount = count;
12673
- }
12643
+ }
12644
+ },
12645
+ onComplete: () => {
12646
+ },
12647
+ timeoutMs: 1e4,
12648
+ timeoutLabel: "fetchAvailableGroups(metadata)"
12649
+ }
12650
+ );
12674
12651
  return Array.from(groupsMap.values());
12675
12652
  }
12676
12653
  async joinGroup(groupId, inviteCode) {
@@ -13475,6 +13452,7 @@ var GroupChatModule = class {
13475
13452
  let name = "Unnamed Group";
13476
13453
  let description;
13477
13454
  let picture;
13455
+ let memberCount;
13478
13456
  let isPrivate = false;
13479
13457
  let writeRestricted = false;
13480
13458
  if (event.content && event.content.trim()) {
@@ -13495,6 +13473,7 @@ var GroupChatModule = class {
13495
13473
  if (tag[0] === "private") isPrivate = true;
13496
13474
  if (tag[0] === "public" && tag[1] === "false") isPrivate = true;
13497
13475
  if (tag[0] === "write-restricted") writeRestricted = true;
13476
+ if (tag[0] === "member_count" && tag[1]) memberCount = parseInt(tag[1], 10) || void 0;
13498
13477
  }
13499
13478
  return {
13500
13479
  id: groupId,
@@ -13502,6 +13481,7 @@ var GroupChatModule = class {
13502
13481
  name,
13503
13482
  description,
13504
13483
  picture,
13484
+ memberCount,
13505
13485
  visibility: isPrivate ? GroupVisibility.PRIVATE : GroupVisibility.PUBLIC,
13506
13486
  writeRestricted: writeRestricted || void 0,
13507
13487
  createdAt: event.created_at * 1e3