Skip to content

Commit 9a2467d

Browse files
committed
added readme update
1 parent 3078648 commit 9a2467d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ await client.conversations.sync();
5252
await client.conversations.messages();
5353
```
5454

55+
### Conversations can be of type `Group` or `Dm`
56+
57+
The new `Group` and `Dm` classes extend the `Conversation` class and provide specific functionality based on the conversation type.
58+
59+
```tsx
60+
const conversations: (Group | Dm)[] = await client.conversations.list();
61+
62+
for (const conversation of conversations) {
63+
// narrow the type to Group to access the group name
64+
if (conversation instanceof Group) {
65+
console.log(group.name);
66+
}
67+
68+
// narrow the type to Dm to access the peer inboxId
69+
if (conversation instanceof Dm) {
70+
console.log(conversation.peerInboxId);
71+
}
72+
}
73+
```
74+
5575
### Working with addresses
5676

5777
Conversations in XMTP can be `DMs` or `Groups`. The underlying technicalities are the same, but DMs are essentially groups locked between two users that can be reused - basically a fixed group of 2. This is how MLS works.

examples/gated-group/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async function main() {
3838

3939
const identifier = await signer.getIdentifier();
4040
const address = identifier.identifier;
41+
4142
console.log(
4243
`Agent initialized on ${address}\nSend a message on http://xmtp.chat/dm/${address}`,
4344
);

0 commit comments

Comments
 (0)