progress on slow mode

This commit is contained in:
groovinchip
2021-07-26 11:42:24 -04:00
parent 848aa550f7
commit 9fb60e93c1
9 changed files with 178 additions and 16 deletions
@@ -130,6 +130,9 @@ class Channel {
return state?.channelStateStream.map((cs) => cs.channel?.cooldown);
}
///
DateTime? cooldownStartedAt;
/// Channel creation date
DateTime? get createdAt {
_checkInitialized();
@@ -429,6 +432,9 @@ class Channel {
skipPush: skipPush,
);
state!.addMessage(response.message);
if (cooldown! > 0) {
cooldownStartedAt = DateTime.now();
}
return response;
} catch (e) {
if (e is StreamChatNetworkError && e.isRetriable) {
@@ -827,6 +833,20 @@ class Channel {
return _client.updateChannelPartial(id!, type, set: set, unset: unset);
}
/// Enable slow mode
Future<UpdateChannelResponse> enableSlowMode({
required int cooldownInterval,
}) async {
_checkInitialized();
return _client.enableSlowdown(id!, type, cooldownInterval);
}
/// Disable slow mode
Future<UpdateChannelResponse> disableSlowMode() async {
_checkInitialized();
return _client.disableSlowdown(id!, type);
}
/// Delete this channel. Messages are permanently removed.
Future<EmptyResponse> delete() async {
_checkInitialized();