From edb05fb723ca0f70ea6ccdf96b65ddf273cb8445 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Feb 2021 12:17:27 +0100 Subject: [PATCH] add disconnect --- src/App.js | 11 +++++------ src/RemixClient.js | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index b590e08d69..695b12889a 100644 --- a/src/App.js +++ b/src/App.js @@ -7,11 +7,6 @@ function App() { const openModal = () => { p.onConnect() } - const clearLocalStorage = () => { - localStorage.clear() - document.getElementById('accounts').innerHTML = '' - document.getElementById('chain').innerHTML = '' - } p.internalEvents.on('accountsChanged', (accounts) => { document.getElementById('accounts').innerHTML = JSON.stringify(accounts) }) @@ -19,11 +14,15 @@ function App() { p.internalEvents.on('chainChanged', (chain) => { document.getElementById('chain').innerHTML = chain }) + + p.internalEvents.on('disconnect', (chain) => { + document.getElementById('accounts').innerHTML = '' + document.getElementById('chain').innerHTML = '' + }) return (
-
diff --git a/src/RemixClient.js b/src/RemixClient.js index d285397635..e13aeb14a6 100644 --- a/src/RemixClient.js +++ b/src/RemixClient.js @@ -65,6 +65,11 @@ export class RemixClient extends PluginClient { this.provider.on("networkChanged", (networkId) => { this.internalEvents.emit('networkChanged', networkId) }); + + // Subscribe to networkId change + this.provider.on("disconnect", () => { + this.internalEvents.emit('disconnect') + }); } getProviderOptions () {