-
Notifications
You must be signed in to change notification settings - Fork 4
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
Don't wait for logging + Cache internet connection status #853
Conversation
WalkthroughThe recent updates focus on optimizing network-related functionalities within the project. Key changes include removing redundant Changes
Poem
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- lib/core/network/certificate_check_interceptor.dart (2 hunks)
- lib/core/network/network_info.dart (1 hunks)
- lib/core/network/token_interceptor.dart (2 hunks)
Additional comments not posted (5)
lib/core/network/network_info.dart (2)
4-4
: EnsureisConnected
is initialized correctly.The
bool get isConnected
declaration in the mixinNetworkInfo
implies thatisConnected
should be initialized properly in the implementing class.Ensure
isConnected
is correctly initialized and updated in all scenarios.
8-18
: Verify initialization and updates ofisConnected
.Ensure that
isConnected
is correctly initialized and updated based on the internet connection status. The current implementation initializesisConnected
based on the initial check and listens for status changes.Ensure that the internet connection status is accurately reflected in
isConnected
.lib/core/network/token_interceptor.dart (3)
1-1
: Ensuredart:async
import is necessary.The
dart:async
import is added. Verify if it is necessary for theunawaited
usage.Ensure that the
dart:async
import is required and used appropriately.
41-45
: Correct usage ofunawaited
for error logging.The
unawaited
function is used to handle the error logging asynchronously. Ensure that this does not lead to unhandled exceptions.Ensure that the
unawaited
usage is appropriate and does not lead to unhandled exceptions.
49-54
: Correct usage ofunawaited
for request logging.The
unawaited
function is used to handle the request logging asynchronously. Ensure that this does not lead to unhandled exceptions.Ensure that the
unawaited
usage is appropriate and does not lead to unhandled exceptions.
|
||
@override | ||
Future<bool> get isConnected => connectionChecker.hasInternetAccess; | ||
bool isConnected = true; |
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.
Avoid redundant initialization of isConnected
.
The isConnected
variable is initialized to true
but is immediately updated based on the internet connection status.
Consider initializing isConnected
to false
and updating it based on the initial check.
- bool isConnected = true;
+ bool isConnected = false;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
bool isConnected = true; | |
bool isConnected = false; |
@@ -12,9 +12,10 @@ class CertificateCheckInterceptor extends InterceptorContract { | |||
@override | |||
Future<BaseRequest> interceptRequest({required BaseRequest request}) async { | |||
/// Don't check for certificate if there is no internet connection | |||
if (await getIt<NetworkInfo>().isConnected == false) { | |||
if (getIt<NetworkInfo>().isConnected == false) { |
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.
Avoid redundant null check for isConnected
.
The internet connection check uses == false
which is redundant and can be simplified.
Simplify the internet connection check.
- if (getIt<NetworkInfo>().isConnected == false) {
+ if (!getIt<NetworkInfo>().isConnected) {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (getIt<NetworkInfo>().isConnected == false) { | |
if (!getIt<NetworkInfo>().isConnected) { |
Summary by CodeRabbit