File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class AuthenticationBloc
4747
4848 final AuthRepository _authenticationRepository;
4949 late final StreamSubscription <User ?> _userAuthSubscription;
50+ Timer ? _cooldownTimer;
5051
5152 /// Handles [_AuthenticationStatusChanged] events.
5253 Future <void > _onAuthenticationStatusChanged (
@@ -97,7 +98,8 @@ class AuthenticationBloc
9798 );
9899
99100 // Start a timer to transition out of cooldown
100- Timer (
101+ _cooldownTimer? .cancel ();
102+ _cooldownTimer = Timer (
101103 _requestCodeCooldownDuration,
102104 () => add (const AuthenticationCooldownCompleted ()),
103105 );
@@ -213,6 +215,7 @@ class AuthenticationBloc
213215 @override
214216 Future <void > close () {
215217 _userAuthSubscription.cancel ();
218+ _cooldownTimer? .cancel ();
216219 return super .close ();
217220 }
218221}
Original file line number Diff line number Diff line change @@ -222,10 +222,8 @@ class _EmailLinkFormState extends State<_EmailLinkForm> {
222222 setState (() {
223223 _cooldownSeconds = 0 ;
224224 });
225- // Optionally, trigger an event to reset the bloc state if needed
226- context
227- .read <AuthenticationBloc >()
228- .add (const AuthenticationCooldownCompleted ());
225+ // The BLoC handles resetting its own state. The UI timer is only
226+ // responsible for updating the countdown on the screen.
229227 }
230228 });
231229 }
You can’t perform that action at this time.
0 commit comments