From 22cf4c6cce08822c5bdf5be045321d3909924c97 Mon Sep 17 00:00:00 2001 From: fabri Date: Mon, 15 Apr 2024 09:52:47 -0300 Subject: [PATCH 1/5] update --- docs/build/group-chat.md | 171 ++++++++++++++++++++++++++------------- 1 file changed, 115 insertions(+), 56 deletions(-) diff --git a/docs/build/group-chat.md b/docs/build/group-chat.md index 5688ef7b..0628f338 100644 --- a/docs/build/group-chat.md +++ b/docs/build/group-chat.md @@ -127,60 +127,6 @@ Code sample coming soon -## Synchronizing group conversations - -XMTP's `syncGroups` brings the current data from the network and updates local DB, reflecting new groups or membership changes. Use `syncGroups` to: - -- **After Signing In:** Immediately update group conversation data. -- **Periodically:** Keep data current based on your app's requirements. -- **After Receiving a Notification:** Reflect changes in group membership prompted by notifications. - - - - -```jsx -await client.conversations.syncGroups(); -``` - - - - -```kotlin -client.conversations.syncGroups() -``` - -List all conversations for both group and individual conversations. - -```kotlin -// List all conversations, including both group and individual -val conversations = client.conversations.list(includeGroups = true) -``` - - - - -```swift -try await client.conversations.sync() -``` - - - - -Code sample coming soon - - - - -At present, the JavaScript SDK lacks support for Group Chat functionalities. Nevertheless, for those looking to integrate backend features, the CLI provides a viable solution, as detailed in [this repository](https://github.com/xmtp/libxmtp/tree/main/examples/cli). For practical application, an example implementation is available on [Replit](https://replit.com/@neekolas/Groups-Nodejs-Client#src/index.ts). To explore group functionalities further, refer to the comprehensive [Token Gated Group Chat Tutorial](/docs/tutorials/token-gated-group-chat). - - - - -Code sample coming soon - - - - ## List group chat conversations Retrieve all existing group chat conversations associated with the current XMTP client. Refer to the [Conversations](/docs/build/conversations.md) section for more details. @@ -337,8 +283,6 @@ Code sample coming soon -_Use the `sync()` method on a group chat object to update its state with the latest information from the XMTP network._ - ## Manage group chat members You can list, add and remove members from a group chat. Only the creator of the group chat has the permissions to add or remove members. This restriction ensures that only authorized individuals can modify the participant list. Developers should design their application's user interface and functionality with this consideration in mind, ensuring that options to add or remove members are only available to the group's creator. @@ -472,6 +416,32 @@ Code sample coming soon +## Manage group chat names + +Group chats in XMTP can have names to help users identify them easily. Here's how to manage these names: + +### Retrieve group name + +To get the current name of a group chat: + +```jsx +const groupName = await group.groupName(); +``` + +### Update group name + +To update the name of a group chat: + +```jsx +await group.updateGroupName("New Group Name"); +``` + +_Remember to do `await group.sync()` syncronizing the group's data including the name_ + +### Synchronization of group names + +Group names are updated across all clients after synchronization. If a group name is changed, other members will see the updated name only after they perform a sync operation on their group data. + ## Listen for new messages and updates Streams enable real-time monitoring of new messages in a group chat as well as member management activities like adding and removing members. Here's how you can set up a stream for message updates. Refer to this [section](/docs/build/streams.md) for more details on streams. @@ -652,6 +622,95 @@ Code sample coming soon +## Synchronization of Group Chats + +XMTP's sync methods brings the current data from the network and updates local DB, reflecting new groups or membership changes. + +### `client.conversations.syncGroups()` + +- **After Signing In:** Immediately update group conversation data. +- **Periodically:** Keep data current based on your app's requirements. +- **After Receiving a Notification:** Reflect changes in group membership prompted by notifications. + + + + +```jsx +// List groups without syncing with the network +let groups = await client.conversations.listGroups(true); +console.log(groups.length); // Might be 0 if not synced after group creation +// Sync groups and list again +await client.conversations.syncGroups(); +groups = await client.conversations.listGroups(true); +console.log(groups.length); // Reflects the actual number of groups +``` + + + + +```kotlin +client.conversations.syncGroups() +``` + +List all conversations for both group and individual conversations. + +```kotlin +// List all conversations, including both group and individual +val conversations = client.conversations.list(includeGroups = true) +``` + + + + +```swift +try await client.conversations.sync() +``` + + + + +Code sample coming soon + + + + +At present, the JavaScript SDK lacks support for Group Chat functionalities. Nevertheless, for those looking to integrate backend features, the CLI provides a viable solution, as detailed in [this repository](https://github.com/xmtp/libxmtp/tree/main/examples/cli). For practical application, an example implementation is available on [Replit](https://replit.com/@neekolas/Groups-Nodejs-Client#src/index.ts). To explore group functionalities further, refer to the comprehensive [Token Gated Group Chat Tutorial](/docs/tutorials/token-gated-group-chat). + + + + +Code sample coming soon + + + + +### `group.sync()` + +This method is used to synchronize specific data for a single group, such as new messages and membership changes. It ensures that the group's data is up-to-date with the latest changes from the network. + +```jsx +// Assume group is an existing group chat object +await group.sync(); // Synchronizes the group's messages and members +// Fetch messages without network sync +const messages = await group.messages(true); +console.log(messages.length); // Shows messages fetched from local data +``` + +#### Using the `skipSync` Parameter + +The `skipSync` parameter is available in methods like `conversations.listGroups()`, `group.messages()`, and `group.memberAddresses()`. It controls whether to synchronize with the network before fetching data: + +- **`true`**: Data is fetched directly from the local database without a network call. This can be faster but might not reflect the most recent changes. +- **`false`** (default): Data is synchronized with the network before fetching, ensuring that the most up-to-date information is retrieved. + +#### Best Practices + +- Use `client.conversations.syncGroups()` to ensure your list of groups is up-to-date before displaying them in your application. +- Use `group.sync()` to fetch the latest messages and member updates for a specific group, especially after known changes like adding new members. +- Consider the application's need for data freshness versus response speed when deciding whether to use the `skipSync` parameter. + +This section aims to clarify the synchronization process, helping developers choose the appropriate methods and parameters based on their specific needs for data accuracy and performance. + ## Note on conversations and messages in group chats It's important to note that all the features and methods described in the [Conversations](/docs/build/conversations) and [Messages](/docs/build/messages) documentation are fully applicable to group chats as well. This includes starting new conversations, checking if an address is on the network, sending messages, and listing existing conversations. XMTP's API design ensures that you can manage group chats with the same ease and flexibility as one-on-one conversations. From c7d011cd6a6e847c2189a5a84ac07b376fb53038 Mon Sep 17 00:00:00 2001 From: fabri Date: Thu, 18 Apr 2024 17:06:09 -0300 Subject: [PATCH 2/5] update --- .gitignore | 4 +++- docs/build/group-chat.md | 42 ++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 3d32131b..ec0bf790 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ yarn-error.log* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json -!.vscode/extensions.json \ No newline at end of file +!.vscode/extensions.json + +docs/build/grouptests.ts \ No newline at end of file diff --git a/docs/build/group-chat.md b/docs/build/group-chat.md index 0628f338..2f08cdc4 100644 --- a/docs/build/group-chat.md +++ b/docs/build/group-chat.md @@ -33,8 +33,8 @@ Initiate a new group chat with a list of specified addresses. To create a group, ```jsx const group = await client.conversations.newGroup( [walletAddress1, walletAddress2], - // Set permissions for the group. Options include "creator_is_admin" where only the creator has admin rights, or "everyone_is_admin" where all members are admins. - { permissions: "creator_is_admin" }, + // Set permissions for the group. Options include "creator_admin" where only the creator has admin rights, or "everyone_is_admin" where all members are admins. + { permissions: "creator_admin" }, ); ``` @@ -43,8 +43,8 @@ const group = await client.conversations.newGroup( ```kotlin val group = client.conversations.newGroup(listOf(walletAddress1, walletAddress2), - // Set permissions for the group. Options include "creator_is_admin" where only the creator has admin rights, or "everyone_is_admin" where all members are admins. - permissions = "creator_is_admin" + // Set permissions for the group. Options include "creator_admin" where only the creator has admin rights, or "everyone_is_admin" where all members are admins. + permissions = "creator_admin" ) ``` @@ -53,8 +53,8 @@ val group = client.conversations.newGroup(listOf(walletAddress1, walletAddress2) ```swift let group = try await client.conversations.newGroup(with: [walletAddress1, walletAddress2], -// Set permissions for the group. Options include "creator_is_admin" where only the creator has admin rights, or "everyone_is_admin" where all members are admins. -permissions: "creator_is_admin") +// Set permissions for the group. Options include "creator_admin" where only the creator has admin rights, or "everyone_is_admin" where all members are admins. +permissions: "creator_admin") ``` @@ -622,6 +622,36 @@ Code sample coming soon +To enhance the documentation on group member management in XMTP, you can add details about the methods used to manage group permissions and member statuses, such as allowing or denying groups, and checking these permissions. Here's a proposed addition to the [docs/build/group-chat.md](file:///Users/fabrizioguespe/DevRel/xmtp-dot-org/docs/build/group-chat.md#1%2C1-1%2C1): + +### Manage group member consent + +In XMTP, you can not only add or remove members from a group chat but also manage permissions regarding who is allowed or denied access to the group. This feature is crucial for maintaining control over group interactions and ensuring that only authorized members can participate. + +#### Allow and deny group access + +You can explicitly allow or deny members' access to a group chat. This is particularly useful in scenarios where group membership needs to be tightly controlled. + +```jsx +// Allow a member to access a group +await group.allowMembers([walletAddress]); + +// Deny a member's access to a group +await group.denyMembers([walletAddress]); +``` + +#### Check if a group is allowed or denied + +You can check if a group is allowed or denied for a member. This method helps in managing user experiences and accessibilities based on their group status. + +```jsx +// Check if a group is allowed for a member +const isAllowed = await group.isGroupAllowed(walletAddress); + +// Check if a group is denied for a member +const isDenied = await group.isGroupDenied(walletAddress); +``` + ## Synchronization of Group Chats XMTP's sync methods brings the current data from the network and updates local DB, reflecting new groups or membership changes. From fe21ce304f624824d0ce6e83d5fc61ffb2923fd4 Mon Sep 17 00:00:00 2001 From: fabri Date: Thu, 18 Apr 2024 17:09:18 -0300 Subject: [PATCH 3/5] update --- docs/build/group-chat.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/build/group-chat.md b/docs/build/group-chat.md index 2f08cdc4..86840f1a 100644 --- a/docs/build/group-chat.md +++ b/docs/build/group-chat.md @@ -622,8 +622,6 @@ Code sample coming soon -To enhance the documentation on group member management in XMTP, you can add details about the methods used to manage group permissions and member statuses, such as allowing or denying groups, and checking these permissions. Here's a proposed addition to the [docs/build/group-chat.md](file:///Users/fabrizioguespe/DevRel/xmtp-dot-org/docs/build/group-chat.md#1%2C1-1%2C1): - ### Manage group member consent In XMTP, you can not only add or remove members from a group chat but also manage permissions regarding who is allowed or denied access to the group. This feature is crucial for maintaining control over group interactions and ensuring that only authorized members can participate. From 4e955ef3e01c633a1c8b48bfdf81a04ee8fa7292 Mon Sep 17 00:00:00 2001 From: fabri Date: Thu, 18 Apr 2024 17:16:50 -0300 Subject: [PATCH 4/5] update --- docs/build/group-chat.md | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/docs/build/group-chat.md b/docs/build/group-chat.md index 86840f1a..15b32eb6 100644 --- a/docs/build/group-chat.md +++ b/docs/build/group-chat.md @@ -624,7 +624,7 @@ Code sample coming soon ### Manage group member consent -In XMTP, you can not only add or remove members from a group chat but also manage permissions regarding who is allowed or denied access to the group. This feature is crucial for maintaining control over group interactions and ensuring that only authorized members can participate. +In XMTP, you can not only add or remove members from a group chat but also manage permissions regarding who is allowed or denied access to the group.Consent is crucial for maintaining control over group interactions and ensuring that only authorized members can participate. To learn more visit [Allow/Block](/docs/build/group-chat) section. #### Allow and deny group access @@ -666,11 +666,11 @@ XMTP's sync methods brings the current data from the network and updates local D ```jsx // List groups without syncing with the network let groups = await client.conversations.listGroups(true); -console.log(groups.length); // Might be 0 if not synced after group creation +// groups length might be 0 if not synced after group creation // Sync groups and list again await client.conversations.syncGroups(); groups = await client.conversations.listGroups(true); -console.log(groups.length); // Reflects the actual number of groups +console.log(groups.length); // groups length reflects the actual number of groups ``` @@ -724,23 +724,6 @@ const messages = await group.messages(true); console.log(messages.length); // Shows messages fetched from local data ``` -#### Using the `skipSync` Parameter - -The `skipSync` parameter is available in methods like `conversations.listGroups()`, `group.messages()`, and `group.memberAddresses()`. It controls whether to synchronize with the network before fetching data: - -- **`true`**: Data is fetched directly from the local database without a network call. This can be faster but might not reflect the most recent changes. -- **`false`** (default): Data is synchronized with the network before fetching, ensuring that the most up-to-date information is retrieved. - -#### Best Practices - -- Use `client.conversations.syncGroups()` to ensure your list of groups is up-to-date before displaying them in your application. -- Use `group.sync()` to fetch the latest messages and member updates for a specific group, especially after known changes like adding new members. -- Consider the application's need for data freshness versus response speed when deciding whether to use the `skipSync` parameter. - -This section aims to clarify the synchronization process, helping developers choose the appropriate methods and parameters based on their specific needs for data accuracy and performance. - ## Note on conversations and messages in group chats It's important to note that all the features and methods described in the [Conversations](/docs/build/conversations) and [Messages](/docs/build/messages) documentation are fully applicable to group chats as well. This includes starting new conversations, checking if an address is on the network, sending messages, and listing existing conversations. XMTP's API design ensures that you can manage group chats with the same ease and flexibility as one-on-one conversations. - -This means that whether you're working with individual conversations or group chats, the process for managing them remains consistent, allowing for a unified and streamlined development experience across different types of communication within XMTP. From ef9d9731eaeaf263a920ee75cabe2d5f9e0bcb51 Mon Sep 17 00:00:00 2001 From: Jennifer Hasegawa <5481259+jhaaaa@users.noreply.github.com> Date: Wed, 22 May 2024 11:27:26 -0700 Subject: [PATCH 5/5] copyedits and style --- docs/build/group-chat.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/build/group-chat.md b/docs/build/group-chat.md index 15b32eb6..23b9cb1a 100644 --- a/docs/build/group-chat.md +++ b/docs/build/group-chat.md @@ -436,7 +436,7 @@ To update the name of a group chat: await group.updateGroupName("New Group Name"); ``` -_Remember to do `await group.sync()` syncronizing the group's data including the name_ +_Remember to do `await group.sync()` synchronizing the group's data including the name_ ### Synchronization of group names @@ -622,11 +622,11 @@ Code sample coming soon -### Manage group member consent +## Manage group member consent -In XMTP, you can not only add or remove members from a group chat but also manage permissions regarding who is allowed or denied access to the group.Consent is crucial for maintaining control over group interactions and ensuring that only authorized members can participate. To learn more visit [Allow/Block](/docs/build/group-chat) section. +With XMTP, in addition to adding and removing members from a group chat, you can also manage permissions that control who is allowed or denied access to the group. Consent is crucial for maintaining control over group interactions and ensuring that only authorized members can participate. To learn more, see [Allow/block](/docs/build/user-consent). -#### Allow and deny group access +### Allow and deny group access You can explicitly allow or deny members' access to a group chat. This is particularly useful in scenarios where group membership needs to be tightly controlled. @@ -638,9 +638,9 @@ await group.allowMembers([walletAddress]); await group.denyMembers([walletAddress]); ``` -#### Check if a group is allowed or denied +### Check if a group is allowed or denied -You can check if a group is allowed or denied for a member. This method helps in managing user experiences and accessibilities based on their group status. +You can check if a group is allowed or denied for a member. This method helps manage user experiences and access based on their group status. ```jsx // Check if a group is allowed for a member @@ -650,15 +650,15 @@ const isAllowed = await group.isGroupAllowed(walletAddress); const isDenied = await group.isGroupDenied(walletAddress); ``` -## Synchronization of Group Chats +## Synchronize group chats -XMTP's sync methods brings the current data from the network and updates local DB, reflecting new groups or membership changes. +XMTP's sync methods bring current data from the network and update the local database. -### `client.conversations.syncGroups()` +### client.conversations.syncGroups() -- **After Signing In:** Immediately update group conversation data. -- **Periodically:** Keep data current based on your app's requirements. -- **After Receiving a Notification:** Reflect changes in group membership prompted by notifications. +- **After signing in**: Immediately update group conversation data. +- **Periodically**: Keep data current based on your app's requirements. +- **After receiving a notification**: Reflect changes in group membership prompted by notifications. @@ -712,9 +712,9 @@ Code sample coming soon -### `group.sync()` +### group.sync() -This method is used to synchronize specific data for a single group, such as new messages and membership changes. It ensures that the group's data is up-to-date with the latest changes from the network. +This method is used to synchronize specific data for a single group, such as new messages and membership changes. It ensures that the group's data is up to date with the latest changes from the network. ```jsx // Assume group is an existing group chat object @@ -726,4 +726,4 @@ console.log(messages.length); // Shows messages fetched from local data ## Note on conversations and messages in group chats -It's important to note that all the features and methods described in the [Conversations](/docs/build/conversations) and [Messages](/docs/build/messages) documentation are fully applicable to group chats as well. This includes starting new conversations, checking if an address is on the network, sending messages, and listing existing conversations. XMTP's API design ensures that you can manage group chats with the same ease and flexibility as one-on-one conversations. +It's important to note that all the features and methods described in [Conversations](/docs/build/conversations) and [Messages](/docs/build/messages) are fully applicable to group chats as well. This includes starting new conversations, checking if an address is on the network, sending messages, and listing existing conversations. XMTP's API design ensures that you can manage group chats with the same ease and flexibility as one-on-one conversations. \ No newline at end of file