Skip to content

Conversation

@michalurbanek
Copy link
Collaborator

Refactored both Google and Apple sign in flows.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Google and Apple sign-in flows to simplify the authentication architecture by removing the intermediate sign_in_with_auth_credential_use_case and directly handling Firebase authentication within each provider-specific use case.

Changes:

  • Separated loading states for Google and Apple sign-in buttons
  • Consolidated sign-in completion logic into a single _signInCompletion method
  • Removed intermediate credential handling use case and integrated Firebase sign-in directly into provider-specific use cases

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
authentication_state.dart Split single isSigningIn flag into separate isGoogleSigningIn and isAppleSigningIn flags; refactored sign-in completion flow
authentication_page_content.dart Updated loading state bindings to use provider-specific flags
authentication_event.dart Added new error event type to handle sign-in errors
sign_in_with_google_use_case.dart Refactored to directly handle Firebase sign-in and exception mapping
sign_in_with_apple_use_case.dart Refactored to directly handle Firebase sign-in with platform-specific logic and exception mapping
sign_in_anonymously_use_case.dart Simplified to only handle Firebase anonymous sign-in
sign_in_with_auth_credential_use_case.dart Removed file - logic consolidated into provider-specific use cases
custom_exception.dart Added Firebase error code mapping for 'web-context-canceled'
README.md Removed completed TODO item

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +60 to 62
// Update current user
await ref.read(currentUserStateProvider.notifier).updateCurrentUser(user);

Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updateCurrentUser is called twice - once inside signInCompletionUseCase (line 31 of that file) and again here. This creates a redundant database write operation. Remove the call from either location to avoid duplication.

Suggested change
// Update current user
await ref.read(currentUserStateProvider.notifier).updateCurrentUser(user);

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +43
setStateData(currentData?.copyWith(isGoogleSigningIn: true));
final provider = ref.read(signInWithGoogleUseCaseProvider.future);
await _signInCompletion(provider);
setStateData(currentData?.copyWith(isGoogleSigningIn: false));
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loading state flag is not reset to false when an exception occurs in _signInCompletion. This causes the button to remain in a loading state after a sign-in error. Wrap the call in a try-finally block to ensure the flag is always reset.

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +50
setStateData(currentData?.copyWith(isAppleSigningIn: true));
final provider = ref.read(signInWithAppleUseCaseProvider.future);
await _signInCompletion(provider);
setStateData(currentData?.copyWith(isAppleSigningIn: false));
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loading state flag is not reset to false when an exception occurs in _signInCompletion. This causes the button to remain in a loading state after a sign-in error. Wrap the call in a try-finally block to ensure the flag is always reset.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants