fix: timer dispose, added widget test
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user