-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Implemented smooth handling of states #2491
Conversation
📝 WalkthroughWalkthroughThe changes refactor the authentication flow across the mobile application. The Changes
Possibly related PRs
Suggested reviewers
Poem
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
mobile-v3/lib/main.dart (2)
215-234
: Consider reintroducing the connectivity banner or removingConnectivityBloc
.Your new implementation omits the
NoInternetBanner
, yet theConnectivityBloc
remains in use. This can introduce confusion for maintainers. If you're no longer showing network warnings, either remove theConnectivityBloc
to reduce complexity or reintroduce the banner to maintain offline handling.
236-247
: Display a dedicated error experience for better user feedback.You're returning a scaffolded error text here, which is acceptable, but consider providing a more descriptive error screen or UX flow (like a retry button or contact support message) to guide users effectively when authentication fails.
mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart (3)
212-226
: Refine fallback when no user data is loaded.If
AuthLoaded
is triggered but user data is still unavailable, showing "Hi, 👋🏼" may confuse users. Consider adding a temporary placeholder or a loading indicator to clarify that user info is still being retrieved.
237-247
: Use a clear message for error states.Returning the same greeting as other states makes it difficult to distinguish errors from normal usage. Provide a distinct error message or a remediation step so the user understands what went wrong.
249-258
: Minimize repeated greetings in fallback states.Multiple states default to "Hi, 👋🏼". To enhance maintainability and keep the UX consistent, consider extracting a dedicated fallback widget or message. This approach reduces duplication and simplifies future enhancements.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
mobile-v3/lib/main.dart
(2 hunks)mobile-v3/lib/src/app/auth/bloc/auth_bloc.dart
(1 hunks)mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart
(4 hunks)
🔇 Additional comments (1)
mobile-v3/lib/src/app/auth/bloc/auth_bloc.dart (1)
74-74
: Verify that removing the delay does not cause flicker or race conditions.If there was no specific reason for the half-second pause, removing it is fine. Otherwise, ensure this change doesn't introduce abrupt UI transitions or race conditions during app startup.
if (authState is AuthLoading) { | ||
|
||
return Text( | ||
"Hi, 👋🏼", | ||
style: TextStyle( | ||
fontSize: 28, | ||
fontWeight: FontWeight.w700, | ||
color: Theme.of(context).textTheme.headlineLarge?.color, | ||
), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Show a loading indicator for consistency during AuthLoading
.
At present, you return "Hi, 👋🏼" while the auth state is loading, whereas main.dart
displays a spinner for loading. Consider showing a similar spinner here to keep a unified loading experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mozart299 do i need to do this? Initially the app does not show a loading indicator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Karagwa Don't add anything for now
mobile-v3/lib/main.dart
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Karagwa I see you have completely removed the connectivity banner and that error state? why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Karagwa So what happens when someone has internet issues? how do they get warned about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
mobile-v3/lib/main.dart (2)
128-138
: Remove commented out theme configuration code.The commented out theme configuration code should be removed since it's not being used and the app is using
AppTheme
instead.- // theme: isLightTheme ? ThemeData( - // splashColor: Colors.transparent, - // highlightColor: Colors.transparent, - // fontFamily: "Inter", - // useMaterial3: true, - // appBarTheme: AppBarTheme( - // scrolledUnderElevation: 0, - // elevation: 0, - // backgroundColor: Theme.of(context).scaffoldBackgroundColor), - // scaffoldBackgroundColor: Theme.of(context).scaffoldBackgroundColor, - // brightness: Brightness.light),
148-203
: Remove commented out old Decider implementation.The old implementation should be removed since it's been replaced with the new BlocBuilder approach. If needed, this code can be retrieved from version control history.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
mobile-v3/lib/main.dart
(3 hunks)
🔇 Additional comments (2)
mobile-v3/lib/main.dart (2)
33-63
: LGTM! Well-structured initialization with proper error handling.The main function follows best practices with proper error handling, async initialization, and clean dependency injection.
217-250
: LGTM! Improved state management with comprehensive error handling.The new implementation:
- Uses BlocBuilder for better state management
- Handles all authentication states properly
- Provides clear error messages to users
- Maintains good debugging with state logging
Summary of Changes (What does this PR do?)
Status of maturity (all need to be checked before merging):
How should this be manually tested?
What are the relevant tickets?
Screenshots (optional)
Summary by CodeRabbit
New Features
Style