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

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

Merged
merged 4 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/scripts/inpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
/**
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/lib/auto-reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down