fix: timer dispose, added widget test

This commit is contained in:
Deven Joshi
2021-08-19 18:03:34 +05:30
parent ddf33a1989
commit 5cd59f2277
2 changed files with 69 additions and 1 deletions
@@ -318,6 +318,8 @@ class MessageInputState extends State<MessageInput> {
late DateTime? _cooldownStartedAt;
int? _timeOut;
Timer? slowModeTimer;
@override
void initState() {
super.initState();
@@ -359,7 +361,7 @@ class MessageInputState extends State<MessageInput> {
StreamChannel.of(context).channel.cooldown!) {
_timeOut = StreamChannel.of(context).channel.cooldown! -
DateTime.now().difference(_cooldownStartedAt!).inSeconds;
Timer.periodic(const Duration(seconds: 1), (timer) {
slowModeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_timeOut == 0) {
timer.cancel();
} else {
@@ -2265,6 +2267,7 @@ class MessageInputState extends State<MessageInput> {
_emojiOverlay?.remove();
_mentionsOverlay?.remove();
_keyboardListener?.cancel();
slowModeTimer?.cancel();
super.dispose();
}