@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/core/index.cjs +20 -40
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +20 -40
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +20 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12823,47 +12823,24 @@ var GroupChatModule = class {
|
|
|
12823
12823
|
await this.ensureConnected();
|
|
12824
12824
|
if (!this.client) return [];
|
|
12825
12825
|
const groupsMap = /* @__PURE__ */ new Map();
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
const
|
|
12833
|
-
if (
|
|
12834
|
-
|
|
12835
|
-
if (!existing || group.createdAt > existing.createdAt) {
|
|
12836
|
-
groupsMap.set(group.id, group);
|
|
12837
|
-
}
|
|
12838
|
-
}
|
|
12839
|
-
},
|
|
12840
|
-
onComplete: () => {
|
|
12841
|
-
},
|
|
12842
|
-
timeoutMs: 1e4,
|
|
12843
|
-
timeoutLabel: "fetchAvailableGroups(metadata)"
|
|
12844
|
-
}
|
|
12845
|
-
),
|
|
12846
|
-
this.oneshotSubscription(
|
|
12847
|
-
new Filter3({ kinds: [NIP29_KINDS.GROUP_MEMBERS] }),
|
|
12848
|
-
{
|
|
12849
|
-
onEvent: (event) => {
|
|
12850
|
-
const groupId = this.getGroupIdFromMetadataEvent(event);
|
|
12851
|
-
if (groupId) {
|
|
12852
|
-
const pTags = event.tags.filter((t) => t[0] === "p");
|
|
12853
|
-
memberCountsMap.set(groupId, pTags.length);
|
|
12826
|
+
await this.oneshotSubscription(
|
|
12827
|
+
new Filter3({ kinds: [NIP29_KINDS.GROUP_METADATA] }),
|
|
12828
|
+
{
|
|
12829
|
+
onEvent: (event) => {
|
|
12830
|
+
const group = this.parseGroupMetadata(event);
|
|
12831
|
+
if (group && group.visibility === GroupVisibility.PUBLIC) {
|
|
12832
|
+
const existing = groupsMap.get(group.id);
|
|
12833
|
+
if (!existing || group.createdAt > existing.createdAt) {
|
|
12834
|
+
groupsMap.set(group.id, group);
|
|
12854
12835
|
}
|
|
12855
|
-
}
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
for (const [groupId, count] of memberCountsMap) {
|
|
12864
|
-
const group = groupsMap.get(groupId);
|
|
12865
|
-
if (group) group.memberCount = count;
|
|
12866
|
-
}
|
|
12836
|
+
}
|
|
12837
|
+
},
|
|
12838
|
+
onComplete: () => {
|
|
12839
|
+
},
|
|
12840
|
+
timeoutMs: 1e4,
|
|
12841
|
+
timeoutLabel: "fetchAvailableGroups(metadata)"
|
|
12842
|
+
}
|
|
12843
|
+
);
|
|
12867
12844
|
return Array.from(groupsMap.values());
|
|
12868
12845
|
}
|
|
12869
12846
|
async joinGroup(groupId, inviteCode) {
|
|
@@ -13668,6 +13645,7 @@ var GroupChatModule = class {
|
|
|
13668
13645
|
let name = "Unnamed Group";
|
|
13669
13646
|
let description;
|
|
13670
13647
|
let picture;
|
|
13648
|
+
let memberCount;
|
|
13671
13649
|
let isPrivate = false;
|
|
13672
13650
|
let writeRestricted = false;
|
|
13673
13651
|
if (event.content && event.content.trim()) {
|
|
@@ -13688,6 +13666,7 @@ var GroupChatModule = class {
|
|
|
13688
13666
|
if (tag[0] === "private") isPrivate = true;
|
|
13689
13667
|
if (tag[0] === "public" && tag[1] === "false") isPrivate = true;
|
|
13690
13668
|
if (tag[0] === "write-restricted") writeRestricted = true;
|
|
13669
|
+
if (tag[0] === "member_count" && tag[1]) memberCount = parseInt(tag[1], 10) || void 0;
|
|
13691
13670
|
}
|
|
13692
13671
|
return {
|
|
13693
13672
|
id: groupId,
|
|
@@ -13695,6 +13674,7 @@ var GroupChatModule = class {
|
|
|
13695
13674
|
name,
|
|
13696
13675
|
description,
|
|
13697
13676
|
picture,
|
|
13677
|
+
memberCount,
|
|
13698
13678
|
visibility: isPrivate ? GroupVisibility.PRIVATE : GroupVisibility.PUBLIC,
|
|
13699
13679
|
writeRestricted: writeRestricted || void 0,
|
|
13700
13680
|
createdAt: event.created_at * 1e3
|