1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00

Stop reloading dapps on network change allowing dapps to decide if it should refresh or not (#6330)

* feat: `inpageProvider.autoRefreshOnNetworkChange` to allow dapps to control if it refreshes or not

* feat: check the `autoRefreshOnNetworkChange` before a refresh

* fix linting error

* fix: use `window.ethereum` now `web3.ethereum`
This commit is contained in:
Josh Stevens 2019-03-21 19:42:23 +00:00 committed by Dan Finlay
parent e1af6312ce
commit 2aaec1d9fb
2 changed files with 8 additions and 0 deletions

View File

@ -91,6 +91,10 @@ inpageProvider.enable = function ({ force } = {}) {
})
}
// give the dapps control of a refresh they can toggle this off on the window.ethereum
// this will be default true so it does not break any old apps.
inpageProvider.autoRefreshOnNetworkChange = true
// add metamask-specific convenience methods
inpageProvider._metamask = new Proxy({
/**

View File

@ -20,6 +20,10 @@ function setupDappAutoReload (web3, observable) {
})
observable.subscribe(function (state) {
// if the auto refresh on network change is false do not
// do anything
if (!window.ethereum.autoRefreshOnNetworkChange) return
// if reload in progress, no need to check reload logic
if (reloadInProgress) return