Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/authentication/bloc/authentication_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AuthenticationBloc

final AuthRepository _authenticationRepository;
late final StreamSubscription<User?> _userAuthSubscription;
Timer? _cooldownTimer;

/// Handles [_AuthenticationStatusChanged] events.
Future<void> _onAuthenticationStatusChanged(
Expand Down Expand Up @@ -97,7 +98,8 @@ class AuthenticationBloc
);

// Start a timer to transition out of cooldown
Timer(
_cooldownTimer?.cancel();
_cooldownTimer = Timer(
_requestCodeCooldownDuration,
() => add(const AuthenticationCooldownCompleted()),
);
Expand Down Expand Up @@ -213,6 +215,7 @@ class AuthenticationBloc
@override
Future<void> close() {
_userAuthSubscription.cancel();
_cooldownTimer?.cancel();
return super.close();
}
}
6 changes: 2 additions & 4 deletions lib/authentication/view/request_code_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,8 @@ class _EmailLinkFormState extends State<_EmailLinkForm> {
setState(() {
_cooldownSeconds = 0;
});
// Optionally, trigger an event to reset the bloc state if needed
context
.read<AuthenticationBloc>()
.add(const AuthenticationCooldownCompleted());
// The BLoC handles resetting its own state. The UI timer is only
// responsible for updating the countdown on the screen.
}
});
}
Expand Down
Loading