Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Keep proxies in sync across "Select networks for each site" togg…
…ling on/off (#4130) ## Explanation This PR fixes a bug where the proxies used to manage per dapp selected network connections do not stay in sync when the user toggles on or off the "Select networks for each site" preference (which turns request queueing on and off): <img width="367" alt="Screenshot 2024-04-12 at 10 54 52 AM" src="https://github.com/MetaMask/core/assets/34557516/31f6acef-da3e-4ff4-b402-efdde1c6c7bb"> This PR fixes this bug by subscribing to `PreferenceController` changes and, when the "Select networks for each site" toggle is flipped repointing the proxy from the (nested) globally selected network proxy to its own independently managed proxy, and when flipped off repoint the proxy to the globally selected network proxy. To test: pull into [this extension PR](https://github.com/MetaMask/metamask-extension/compare/ad/fix/queue-toggle-proxies?expand=1) -> you'll need to link to a local build of selected-network-controller with these commits. ## Changelog ### `@metamask/selected-network-controller` - **ADD**: **BREAKING:** A parameter `useRequestQueuePreference` which should point to the current preferences state for useRequestQueue is now required by the constructor - **ADD**: An `onPreferencesStateChange` argument that should subscribe to `PreferencesController` state changes and call a callback with the updated state is now a required parameter in the constructor options object. - **REMOVED** - The `getUseRequestQueue` parameter is no longer accepted by the constructor. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate
- Loading branch information