From 2a43fa7d71901adc35e9958f93d8649a121ce99c Mon Sep 17 00:00:00 2001 From: Luka Jeran Date: Fri, 5 Jul 2024 22:22:53 +0200 Subject: [PATCH] Differentiate first AddToMetaMask success and repeated clicks --- src/AddToMetaMask.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AddToMetaMask.tsx b/src/AddToMetaMask.tsx index e143b6e5ef..b840ec8472 100644 --- a/src/AddToMetaMask.tsx +++ b/src/AddToMetaMask.tsx @@ -18,6 +18,7 @@ const AddToMetaMask = (props: { if (!window.ethereum?.request) { return alert('Have you installed MetaMask yet? If not, please do so.\n\nComputer: Once it is installed, you will be able to add the ParaTime to your MetaMask.\n\nPhone: Open the website through your MetaMask Browser to add the ParaTime.') } + const startTime = Date.now() window.ethereum.request({ method: 'wallet_addEthereumChain', params: [ @@ -34,7 +35,7 @@ const AddToMetaMask = (props: { }, ], }).then(response => { - if (response === null) alert('Added') + if (response === null && Date.now() - startTime < 100) alert(`The ${props.name} RPC already added.`) }) }} >