From b989fbc3ad3908b690705d08bd6bc21c432ed6e3 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 30 Jul 2021 11:48:23 +0200 Subject: [PATCH] fix(llc): use channel partial update for slowmode --- .../stream_chat/lib/src/client/channel.dart | 4 ++-- .../stream_chat/lib/src/client/client.dart | 4 ++-- .../lib/src/core/api/channel_api.dart | 24 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index fb579a56..1f6d3edd 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -834,7 +834,7 @@ class Channel { } /// Enable slow mode - Future enableSlowMode({ + Future enableSlowMode({ required int cooldownInterval, }) async { _checkInitialized(); @@ -842,7 +842,7 @@ class Channel { } /// Disable slow mode - Future disableSlowMode() async { + Future disableSlowMode() async { _checkInitialized(); return _client.disableSlowdown(id!, type); } diff --git a/packages/stream_chat/lib/src/client/client.dart b/packages/stream_chat/lib/src/client/client.dart index 7b5cbb35..788bc9cf 100644 --- a/packages/stream_chat/lib/src/client/client.dart +++ b/packages/stream_chat/lib/src/client/client.dart @@ -1248,7 +1248,7 @@ class StreamChatClient { ); /// Enables slow mode - Future enableSlowdown( + Future enableSlowdown( String channelId, String channelType, int cooldown, @@ -1260,7 +1260,7 @@ class StreamChatClient { ); /// Disables slow mode - Future disableSlowdown( + Future disableSlowdown( String channelId, String channelType, ) async => diff --git a/packages/stream_chat/lib/src/core/api/channel_api.dart b/packages/stream_chat/lib/src/core/api/channel_api.dart index 31a64cf8..e8782feb 100644 --- a/packages/stream_chat/lib/src/core/api/channel_api.dart +++ b/packages/stream_chat/lib/src/core/api/channel_api.dart @@ -124,32 +124,32 @@ class ChannelApi { } /// Enable slowdown - Future enableSlowdown( + Future enableSlowdown( String channelId, String channelType, int cooldown, ) async { - final response = await _client.post( - _getChannelUrl(channelId, channelType), - data: { + final response = await updateChannelPartial( + channelId, + channelType, + set: { 'cooldown': cooldown, }, ); - return UpdateChannelResponse.fromJson(response.data); + return response; } /// Disable slowdown - Future disableSlowdown( + Future disableSlowdown( String channelId, String channelType, ) async { - final response = await _client.post( - _getChannelUrl(channelId, channelType), - data: { - 'cooldown': 0, - }, + final response = await updateChannelPartial( + channelId, + channelType, + unset: ['cooldown'], ); - return UpdateChannelResponse.fromJson(response.data); + return response; } /// Accept invitation to the channel