-
-
Notifications
You must be signed in to change notification settings - Fork 267
feat: add new ConnectivityController
#7623
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
Conversation
b14162d to
daa5333
Compare
daa5333 to
5e51275
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
…CTIVITY_STATUSES - Rename ConnectivityStatus constant to CONNECTIVITY_STATUSES - Export ConnectivityStatus as a type instead of enum - Update all references to use CONNECTIVITY_STATUSES - Export CONNECTIVITY_STATUSES from index
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
mcmire
left a comment
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.
Last round of feedback, I think. Everything else looks good beyond this.
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
packages/connectivity-controller/src/ConnectivityController.test.ts
Outdated
Show resolved
Hide resolved
mcmire
left a comment
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.
This looks great!
Explanation
This PR introduces a new
@metamask/connectivity-controllerpackage that provides a centralized way to track and manage device internet connectivity status across MetaMask clients (extension and mobile).What is the current state of things and why does it need to change?
What is the solution your changes offer and how does it work?
The
ConnectivityControlleris a platform-agnostic controller that:onlineoroffline) in its stateConnectivityServiceimplementations are injected at construction timestateChangeevents when connectivity status changes, allowing other controllers and UI components to react accordinglyThe controller is designed to work with different service implementations:
NetInfoConnectivityServiceusing@react-native-community/netinfoBrowserConnectivityServiceusing browser APIsAre there any changes whose purpose might not be obvious to those unfamiliar with the domain?
connectivityStatusfield in state is prefixed with "connectivity" to avoid conflicts when state is flattened in Reduxpersist: falsesince connectivity status is ephemeral and should not be restored from storageReferences
Fixes: https://consensyssoftware.atlassian.net/browse/WPC-210
Checklist
Note
Introduce a new, platform-agnostic controller to track device connectivity with adapter-driven status updates.
@metamask/connectivity-controllerexposingConnectivityController,CONNECTIVITY_STATUSES, andConnectivityAdapterinterfacegetStatus()and updates state ononConnectivityChange, with non-persistentconnectivityStatusmetadataCODEOWNERS,teams.json, tsconfig references, andyarn.lockentryWritten by Cursor Bugbot for commit 16c51b5. This will update automatically on new commits. Configure here.