diff --git a/docusaurus/docs/Flutter/stream_chat/deleting_and_hiding_channel.mdx b/docusaurus/docs/Flutter/stream_chat/deleting_and_hiding_channel.mdx index 458a06cc..0630aded 100644 --- a/docusaurus/docs/Flutter/stream_chat/deleting_and_hiding_channel.mdx +++ b/docusaurus/docs/Flutter/stream_chat/deleting_and_hiding_channel.mdx @@ -4,3 +4,34 @@ sidebar_position: 13 title: Deleting And Hiding A Channel --- +### Deleting a Channel + +You can delete a Channel using the delete method. This marks the channel as deleted and hides all the content. + +```dart +await channel.delete(); +``` + +Note: If you recreate this channel, it will show up empty. Recovering old messages is not currently supported via the Stream Chat API. + +### Hiding a Channel + +Hiding a channel will remove it from query channel requests for that user until a new message is added. +Please keep in mind that hiding a channel is only available to members of that channel. + +Optionally you can also clear the entire message history of that channel for the user. +This way, when a new message is received, it will be the only one present in the channel. + +```dart +// hides the channel until a new message is added there +await channel.hide(); + +// shows a previously hidden channel +await channel.show(); + +// hide the channel and clear the message history +await channel.hide(clearHistory: true); +``` + +Note: You can still retrieve the list of hidden channels using the { "hidden" : true } query parameter. + diff --git a/docusaurus/docs/Flutter/stream_chat/invites.mdx b/docusaurus/docs/Flutter/stream_chat/invites.mdx index 7b3532fe..430970cd 100644 --- a/docusaurus/docs/Flutter/stream_chat/invites.mdx +++ b/docusaurus/docs/Flutter/stream_chat/invites.mdx @@ -4,3 +4,58 @@ sidebar_position: 11 title: Invites --- +### Inviting Users + +Stream Chat provides the ability to invite users to a channel via the `channel` method with the `invites` array. +Upon invitation, the end-user will receive a notification that they were invited to the specified channel. + +See the following for an example on how to invite a user by adding an invites array containing the user ID: + +```dart +final invite = client.channel("messaging", id: "awesome-chat", + extraData: { + "name": "Founder Chat", + "members": ["thierry", "tommaso", "nick"], + "invites": ["nick"], + }); + +await invite.create(); +``` + +### Accepting an Invite + +In order to accept an invite, you must use call the `acceptInvite` method. +The `acceptInvite` method accepts and object with an optional `message` property. +Please see below for an example of how to call `acceptInvite`: + +```dart +final channel = client.channel("messaging", id: "awesome-chat"); +await channel.acceptInvite(); +``` + +### Rejecting an Invite + +To reject an invite, call the `rejectInvite` method. +This method does not require a user ID as it pulls the user ID from the current session in store from the `connectUser` call. + +```dart +await channel.rejectInvite(); +``` + +### Query for Accepted Invites + +Querying for accepted invites is done via the `queryChannels` method. +This allows you to return a list of accepted invites with a single call. See below for an example: + +```dart +final invites = await client.queryChannels(filter: {"invite": "accepted"}); +``` + +### Query for Rejected Invites + +Similar to querying for accepted invites, you can query for rejected invites with `queryChannels`. +See below for an example: + +```dart +final rejected = await client.queryChannels(filter: {"invite": "rejected"}); +``` \ No newline at end of file diff --git a/docusaurus/docs/Flutter/stream_chat/muting_channels.mdx b/docusaurus/docs/Flutter/stream_chat/muting_channels.mdx index a6acee75..29874091 100644 --- a/docusaurus/docs/Flutter/stream_chat/muting_channels.mdx +++ b/docusaurus/docs/Flutter/stream_chat/muting_channels.mdx @@ -4,3 +4,59 @@ sidebar_position: 12 title: Muting Channels --- +Messages added to a channel will not trigger push notifications, nor change the unread count for the users that muted it. + +By default, mutes stay in place indefinitely until the user removes it; however, you can optionally set an expiration time. + +The list of muted channels and their expiration time is returned when the user connects. + +### Channel Mute + +```dart +// mute channel for current user +await channel.mute(); + +// mute a channel for 2 weeks +await channel.mute(expiration: Duration(days: 15)); + +// mute a channel for 10 seconds +await channel.mute(expiration: Duration(seconds: 10)); + +// check if channel is muted +channel.isMuted; +``` + +### Query Muted Channels + +Muted channels can be filtered or excluded by using the `muted` in your query channels filter. + +```dart +// retrieve all channels excluding muted ones +await client.queryChannels( + filter: { + 'members': { + r'$in': [userId], + }, + 'muted': false, + } + ); + +// retrieve all muted channels +await client.queryChannels( + filter: { + 'muted': true, + } + ); +``` + +### Remove a Channel Mute + +Whenever you need to unmute, you are able to. + +```dart +// unmute channel for current user +await channel.unmute(); + +// unmute channel for a user (server-side) +await channel.unmute({ user_id: userId }); +```