refactor(llc, ui): make cooldown non-nullable.

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2021-08-25 15:40:26 +05:30
committed by xsahil03x
parent 3ad35602bc
commit 1a99a38469
2 changed files with 32 additions and 30 deletions
@@ -202,15 +202,15 @@ class Channel {
}
/// Cooldown count
int? get cooldown {
int get cooldown {
_checkInitialized();
return state?._channelState.channel?.cooldown;
return state!._channelState.channel?.cooldown ?? 0;
}
/// Cooldown count as a stream
Stream<int?>? get cooldownStream {
Stream<int> get cooldownStream {
_checkInitialized();
return state?.channelStateStream.map((cs) => cs.channel?.cooldown);
return state!.channelStateStream.map((cs) => cs.channel?.cooldown ?? 0);
}
/// Stores time at which cooldown was started
@@ -540,9 +540,7 @@ class Channel {
skipPush: skipPush,
);
state!.addMessage(response.message);
if (cooldown! > 0) {
cooldownStartedAt = DateTime.now();
}
if (cooldown > 0) cooldownStartedAt = DateTime.now();
return response;
} catch (e) {
if (e is StreamChatNetworkError && e.isRetriable) {