diff --git a/docusaurus/docs/Flutter/stream_chat/channel_members.mdx b/docusaurus/docs/Flutter/stream_chat/channel_members.mdx index 3ac1da84..750a9ac7 100644 --- a/docusaurus/docs/Flutter/stream_chat/channel_members.mdx +++ b/docusaurus/docs/Flutter/stream_chat/channel_members.mdx @@ -4,3 +4,30 @@ sidebar_position: 10 title: Channel Members --- +### Adding & Removing Channel Members + +Using the addMembers() method adds the given users as members, while removeMembers() removes them. + +```dart +await channel.addMembers(["thierry", "josh"]); +await channel.removeMembers(["tommaso"]); +``` + +You can optionally include a message object that client-side SDKs will use to populate a system message. +This works for both add and remove members: + +```dart +// using client-side client +await channel.addMembers(['tommaso'], Message(text: 'Tommaso joined')); +``` + +### Leaving a channel + +It is possible for user to leave the channel without moderator-level permissions. +Make sure channel members have `RemoveOwnChannelMembership` permission. + +```dart +// remove own channel membership +await channel.removeMembers(['my_user_id']); +``` + diff --git a/docusaurus/docs/Flutter/stream_chat/updating_channels.mdx b/docusaurus/docs/Flutter/stream_chat/updating_channels.mdx index 75e693eb..a4de1fcd 100644 --- a/docusaurus/docs/Flutter/stream_chat/updating_channels.mdx +++ b/docusaurus/docs/Flutter/stream_chat/updating_channels.mdx @@ -4,3 +4,43 @@ sidebar_position: 9 title: Updating Channels --- +There are two ways to update a channel using the Stream API - a partial or full update. +A partial update will retain any custom key-value data, whereas a complete update is going to remove any that are unspecified in the API request. + +### Partial Update + +A partial update can be used to set and unset specific fields when it is necessary to retain additional custom data fields on the object. +AKA a patch style update. + +```dart +// Here's a channel with some custom field data that might be useful +var channel = client.channel(type, id: id, extraData: { + "source": "user", + "source_detail" :{ "user_id": 123 }, + "channel_detail" :{ "topic": "Plants and Animals", "rating": "pg" } +}); + +// let's change the source of this channel +await channel.updatePartial({ "set" :{ "source": "system" } }); + +// since it's system generated we no longer need source_detail +await channel.updatePartial({ "unset": ["source_detail"] }); + +// and finally update one of the nested fields in the channel_detail +await channel.updatePartial({ "set": { "channel_detail.topic": "Nature" } }); + +// and maybe we decide we no longer need a rating +await channel.updatePartial({ "unset": ["channel_detail.rating"] }); +``` + +### Full Update (overwrite) + +The update function updates all of the channel data. +Any data that is present on the channel and not included in a full update will be deleted. + +```dart +await channel.update({ + "name": "myspecialchannel", + "color": "green", +}, Message(text: "Thierry changed the channel color to green")); +``` \ No newline at end of file