Skip to content

Commit 62b898a

Browse files
authored
Add code sample for IStreamChannel.UpdateOverwriteAsync (#131)
1 parent 376bda3 commit 62b898a

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

Assets/Plugins/StreamChat/Samples/ChannelsCodeSamples.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,30 @@ private class ClanData
294294
/// </summary>
295295
public async Task FullUpdate()
296296
{
297-
//StreamTodo: IMPLEMENT channel full update
298-
await Task.CompletedTask;
297+
var channel = await Client.GetOrCreateChannelWithIdAsync(ChannelType.Messaging, channelId: "my-channel-id");
298+
299+
var updateRequest = new StreamUpdateOverwriteChannelRequest
300+
{
301+
Name = "New name",
302+
CustomData = new StreamCustomDataRequest
303+
{
304+
{ "my-custom-int", 12 },
305+
{ "my-custom-array", new string[] { "one", "two" } }
306+
}
307+
};
308+
309+
// This request will have all channel data removed except what is being passed in the request
310+
await channel.UpdateOverwriteAsync(updateRequest);
311+
312+
// You can also pass an instance of channel to the request constructor to have all of the date copied over
313+
// This way you alter only the fields you wish to change
314+
var updateRequest2 = new StreamUpdateOverwriteChannelRequest(channel)
315+
{
316+
Name = "Bran new name"
317+
};
318+
319+
// This will update only the name because all other data was copied over
320+
await channel.UpdateOverwriteAsync(updateRequest2);
299321
}
300322

301323
#endregion

0 commit comments

Comments
 (0)