diff --git a/lib/authentication/bloc/authentication_bloc.dart b/lib/authentication/bloc/authentication_bloc.dart index b919aca..d307ca8 100644 --- a/lib/authentication/bloc/authentication_bloc.dart +++ b/lib/authentication/bloc/authentication_bloc.dart @@ -38,6 +38,7 @@ class AuthenticationBloc final AuthRepository _authenticationRepository; late final StreamSubscription _userAuthSubscription; + Timer? _cooldownTimer; /// Handles [_AuthenticationUserChanged] events. Future _onAuthenticationUserChanged( @@ -83,7 +84,8 @@ class AuthenticationBloc ), ); - Timer( + _cooldownTimer?.cancel(); + _cooldownTimer = Timer( _requestCodeCooldownDuration, () => add(const AuthenticationCooldownCompleted()), ); @@ -168,6 +170,7 @@ class AuthenticationBloc @override Future close() { _userAuthSubscription.cancel(); + _cooldownTimer?.cancel(); return super.close(); } diff --git a/lib/authentication/view/request_code_page.dart b/lib/authentication/view/request_code_page.dart index 4a812bb..427a94c 100644 --- a/lib/authentication/view/request_code_page.dart +++ b/lib/authentication/view/request_code_page.dart @@ -200,9 +200,6 @@ class _EmailLinkFormState extends State<_EmailLinkForm> { setState(() { _cooldownSeconds = 0; }); - context - .read() - .add(const AuthenticationCooldownCompleted()); } }); }