Skip to content
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

Add network status checker #58

Closed
wants to merge 4 commits into from

Conversation

cp-megh-l
Copy link
Collaborator

@cp-megh-l cp-megh-l commented May 29, 2024

Summary by CodeRabbit

  • New Features

    • Introduced network status monitoring to provide real-time updates on connectivity.
    • Added a new function for network status checks and notifications.
  • Improvements

    • Enhanced network connectivity handling across the application.
    • Improved user session state management for better performance.
  • Bug Fixes

    • Fixed issues related to incorrect network status detection.
    • Resolved problems with user session state updates.
  • Tests

    • Updated tests to include network status checks and improved dependency injection for better test coverage.

Copy link

coderabbitai bot commented May 29, 2024

Walkthrough

The updates primarily focus on enhancing network connectivity management within the YourSpace Android application. Key changes include removing the NetworkConnectionReceiver from the manifest, introducing new network status monitoring mechanisms, and updating various classes to utilize these new mechanisms. Additionally, new utility functions and services were added to handle network status checks, and corresponding test updates were made to support these changes.

Changes

File Path Change Summary
app/src/main/…/AndroidManifest.xml Removed NetworkConnectionReceiver declaration.
app/src/main/…/YourSpaceApplication.kt Added network status monitoring logic and necessary imports.
app/src/main/…/callback/NetworkStatusCallback.kt Added method to update network status and broadcast changes.
app/src/main/…/receiver/BootCompleteReceiver.kt Updated import statement for network connectivity check.
app/src/main/…/receiver/NetworkConnectionReceiver.kt Replaced ConnectivityManager usage with custom action constants.
app/src/main/…/utils/ContextExt.kt Removed isNetWorkConnected() function.
app/src/main/…/utils/NetworkUtils.kt Added utility functions for registering/unregistering network callbacks and checking network connectivity.
data/src/main/…/models/user/ApiUser.kt Modified logic for noNetwork property in ApiUserSession.
data/src/main/…/service/auth/AuthService.kt Updated updateUserSessionState function to remove conditional check.
app/src/main/…/fcm/YourSpaceFcmService.kt Added logic to handle network status notifications and update user session state.
app/src/main/…/ui/flow/home/map/MapViewModel.kt Added network status check using ApiUserService.
app/src/test/…/ui/flow/home/map/MapViewModelTest.kt Added dependency injection for ApiUserService in test class.
data/src/main/…/service/user/ApiUserService.kt Added method for checking user network status and retrying if needed.
functions/index.js Added networkStatusCheck function to check network status and handle notifications.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a2bb12a and 739f20f.

Files selected for processing (6)
  • app/src/main/java/com/canopas/yourspace/domain/fcm/YourSpaceFcmService.kt (4 hunks)
  • app/src/main/java/com/canopas/yourspace/ui/flow/home/map/MapViewModel.kt (3 hunks)
  • app/src/test/java/com/canopas/yourspace/ui/flow/home/map/MapViewModelTest.kt (3 hunks)
  • data/src/main/java/com/canopas/yourspace/data/models/user/ApiUser.kt (2 hunks)
  • data/src/main/java/com/canopas/yourspace/data/service/user/ApiUserService.kt (3 hunks)
  • functions/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • data/src/main/java/com/canopas/yourspace/data/models/user/ApiUser.kt
Additional context used
Biome
functions/index.js

[error] 78-78: Template literals are preferred over string concatenation.


[error] 249-249: Use === instead of ==.
== is only allowed when comparing against null


[error] 267-267: Use === instead of ==.
== is only allowed when comparing against null


[error] 268-268: Use === instead of ==.
== is only allowed when comparing against null


[error] 271-273: This else clause can be omitted because previous branches break early.


[error] 11-11: Use let or const instead of var.


[error] 47-47: Use let or const instead of var.


[error] 72-72: Use let or const instead of var.


[error] 81-81: Use let or const instead of var.


[error] 149-149: Use let or const instead of var.


[error] 166-166: Use let or const instead of var.


[error] 172-172: Use let or const instead of var.


[error] 227-227: Use let or const instead of var.


[error] 237-237: Use let or const instead of var.

Additional comments not posted (6)
app/src/main/java/com/canopas/yourspace/ui/flow/home/map/MapViewModel.kt (2)

13-13: Added import and field for ApiUserService to enable network status checks.

Also applies to: 36-36


120-122: Network status check correctly implemented in showMemberDetail.

data/src/main/java/com/canopas/yourspace/data/service/user/ApiUserService.kt (1)

142-185: Implemented getUserNetworkStatus and retryUserStatusCheck methods to handle network status checks with retry logic.

app/src/test/java/com/canopas/yourspace/ui/flow/home/map/MapViewModelTest.kt (1)

11-11: Correctly added ApiUserService to the test setup to support new network status check functionality.

Also applies to: 40-40, 53-53

app/src/main/java/com/canopas/yourspace/domain/fcm/YourSpaceFcmService.kt (1)

18-19: Added handling for network status notifications and correctly injected AuthService to update session state based on network status.

Also applies to: 74-76, 118-120

functions/index.js (1)

313-354: Implemented networkStatusCheck function to send network status notifications to users.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cp-megh-l cp-megh-l marked this pull request as draft May 29, 2024 10:55
try {
function.call(data).await()
val callTime = System.currentTimeMillis()
retryUserStatusCheck(userId, callTime) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to retry?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We're not sure that we will get sudden update in firestore, so retry after 5 seconds, if we get updated response suddenly then it will skip

@cp-megh-l cp-megh-l marked this pull request as ready for review May 31, 2024 03:03
@cp-megh-l cp-megh-l marked this pull request as draft June 10, 2024 14:03
@cp-megh-l cp-megh-l added the on hold Need to revisit after some decision making label Jun 10, 2024
@cp-megh-l cp-megh-l closed this Aug 12, 2024
@cp-megh-l cp-megh-l reopened this Aug 13, 2024
@cp-sneh-s cp-sneh-s closed this Aug 13, 2024
@cp-sneh-s cp-sneh-s reopened this Aug 15, 2024
@cp-sneh-s cp-sneh-s closed this Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold Need to revisit after some decision making
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants