@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.
@@ -12554,47 +12554,24 @@ var GroupChatModule = class {
12554
12554
  await this.ensureConnected();
12555
12555
  if (!this.client) return [];
12556
12556
  const groupsMap = /* @__PURE__ */ new Map();
12557
- const memberCountsMap = /* @__PURE__ */ new Map();
12558
- await Promise.all([
12559
- this.oneshotSubscription(
12560
- new Filter3({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
12561
- {
12562
- onEvent: (event) => {
12563
- const group = this.parseGroupMetadata(event);
12564
- if (group && group.visibility === GroupVisibility.PUBLIC) {
12565
- const existing = groupsMap.get(group.id);
12566
- if (!existing || group.createdAt > existing.createdAt) {
12567
- groupsMap.set(group.id, group);
12568
- }
12569
- }
12570
- },
12571
- onComplete: () => {
12572
- },
12573
- timeoutMs: 1e4,
12574
- timeoutLabel: "fetchAvailableGroups(metadata)"
12575
- }
12576
- ),
12577
- this.oneshotSubscription(
12578
- new Filter3({ kinds: [NIP29_KINDS.GROUP_MEMBERS] }),
12579
- {
12580
- onEvent: (event) => {
12581
- const groupId = this.getGroupIdFromMetadataEvent(event);
12582
- if (groupId) {
12583
- const pTags = event.tags.filter((t) => t[0] === "p");
12584
- memberCountsMap.set(groupId, pTags.length);
12557
+ await this.oneshotSubscription(
12558
+ new Filter3({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
12559
+ {
12560
+ onEvent: (event) => {
12561
+ const group = this.parseGroupMetadata(event);
12562
+ if (group && group.visibility === GroupVisibility.PUBLIC) {
12563
+ const existing = groupsMap.get(group.id);
12564
+ if (!existing || group.createdAt > existing.createdAt) {
12565
+ groupsMap.set(group.id, group);
12585
12566
  }
12586
- },
12587
- onComplete: () => {
12588
- },
12589
- timeoutMs: 1e4,
12590
- timeoutLabel: "fetchAvailableGroups(members)"
12591
- }
12592
- )
12593
- ]);
12594
- for (const [groupId, count] of memberCountsMap) {
12595
- const group = groupsMap.get(groupId);
12596
- if (group) group.memberCount = count;
12597
- }
12567
+ }
12568
+ },
12569
+ onComplete: () => {
12570
+ },
12571
+ timeoutMs: 1e4,
12572
+ timeoutLabel: "fetchAvailableGroups(metadata)"
12573
+ }
12574
+ );
12598
12575
  return Array.from(groupsMap.values());
12599
12576
  }
12600
12577
  async joinGroup(groupId, inviteCode) {
@@ -13399,6 +13376,7 @@ var GroupChatModule = class {
13399
13376
  let name = "Unnamed Group";
13400
13377
  let description;
13401
13378
  let picture;
13379
+ let memberCount;
13402
13380
  let isPrivate = false;
13403
13381
  let writeRestricted = false;
13404
13382
  if (event.content && event.content.trim()) {
@@ -13419,6 +13397,7 @@ var GroupChatModule = class {
13419
13397
  if (tag[0] === "private") isPrivate = true;
13420
13398
  if (tag[0] === "public" && tag[1] === "false") isPrivate = true;
13421
13399
  if (tag[0] === "write-restricted") writeRestricted = true;
13400
+ if (tag[0] === "member_count" && tag[1]) memberCount = parseInt(tag[1], 10) || void 0;
13422
13401
  }
13423
13402
  return {
13424
13403
  id: groupId,
@@ -13426,6 +13405,7 @@ var GroupChatModule = class {
13426
13405
  name,
13427
13406
  description,
13428
13407
  picture,
13408
+ memberCount,
13429
13409
  visibility: isPrivate ? GroupVisibility.PRIVATE : GroupVisibility.PUBLIC,
13430
13410
  writeRestricted: writeRestricted || void 0,
13431
13411
  createdAt: event.created_at * 1e3