@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.
package/dist/index.cjs CHANGED
@@ -12970,47 +12970,24 @@ var GroupChatModule = class {
12970
12970
  await this.ensureConnected();
12971
12971
  if (!this.client) return [];
12972
12972
  const groupsMap = /* @__PURE__ */ new Map();
12973
- const memberCountsMap = /* @__PURE__ */ new Map();
12974
- await Promise.all([
12975
- this.oneshotSubscription(
12976
- new import_nostr_js_sdk4.Filter({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
12977
- {
12978
- onEvent: (event) => {
12979
- const group = this.parseGroupMetadata(event);
12980
- if (group && group.visibility === GroupVisibility.PUBLIC) {
12981
- const existing = groupsMap.get(group.id);
12982
- if (!existing || group.createdAt > existing.createdAt) {
12983
- groupsMap.set(group.id, group);
12984
- }
12985
- }
12986
- },
12987
- onComplete: () => {
12988
- },
12989
- timeoutMs: 1e4,
12990
- timeoutLabel: "fetchAvailableGroups(metadata)"
12991
- }
12992
- ),
12993
- this.oneshotSubscription(
12994
- new import_nostr_js_sdk4.Filter({ kinds: [NIP29_KINDS.GROUP_MEMBERS] }),
12995
- {
12996
- onEvent: (event) => {
12997
- const groupId = this.getGroupIdFromMetadataEvent(event);
12998
- if (groupId) {
12999
- const pTags = event.tags.filter((t) => t[0] === "p");
13000
- memberCountsMap.set(groupId, pTags.length);
12973
+ await this.oneshotSubscription(
12974
+ new import_nostr_js_sdk4.Filter({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
12975
+ {
12976
+ onEvent: (event) => {
12977
+ const group = this.parseGroupMetadata(event);
12978
+ if (group && group.visibility === GroupVisibility.PUBLIC) {
12979
+ const existing = groupsMap.get(group.id);
12980
+ if (!existing || group.createdAt > existing.createdAt) {
12981
+ groupsMap.set(group.id, group);
13001
12982
  }
13002
- },
13003
- onComplete: () => {
13004
- },
13005
- timeoutMs: 1e4,
13006
- timeoutLabel: "fetchAvailableGroups(members)"
13007
- }
13008
- )
13009
- ]);
13010
- for (const [groupId, count] of memberCountsMap) {
13011
- const group = groupsMap.get(groupId);
13012
- if (group) group.memberCount = count;
13013
- }
12983
+ }
12984
+ },
12985
+ onComplete: () => {
12986
+ },
12987
+ timeoutMs: 1e4,
12988
+ timeoutLabel: "fetchAvailableGroups(metadata)"
12989
+ }
12990
+ );
13014
12991
  return Array.from(groupsMap.values());
13015
12992
  }
13016
12993
  async joinGroup(groupId, inviteCode) {
@@ -13815,6 +13792,7 @@ var GroupChatModule = class {
13815
13792
  let name = "Unnamed Group";
13816
13793
  let description;
13817
13794
  let picture;
13795
+ let memberCount;
13818
13796
  let isPrivate = false;
13819
13797
  let writeRestricted = false;
13820
13798
  if (event.content && event.content.trim()) {
@@ -13835,6 +13813,7 @@ var GroupChatModule = class {
13835
13813
  if (tag[0] === "private") isPrivate = true;
13836
13814
  if (tag[0] === "public" && tag[1] === "false") isPrivate = true;
13837
13815
  if (tag[0] === "write-restricted") writeRestricted = true;
13816
+ if (tag[0] === "member_count" && tag[1]) memberCount = parseInt(tag[1], 10) || void 0;
13838
13817
  }
13839
13818
  return {
13840
13819
  id: groupId,
@@ -13842,6 +13821,7 @@ var GroupChatModule = class {
13842
13821
  name,
13843
13822
  description,
13844
13823
  picture,
13824
+ memberCount,
13845
13825
  visibility: isPrivate ? GroupVisibility.PRIVATE : GroupVisibility.PUBLIC,
13846
13826
  writeRestricted: writeRestricted || void 0,
13847
13827
  createdAt: event.created_at * 1e3