From caa9a22d6970df331eebed032b9a9673d4217fc6 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 6 Dec 2021 15:27:20 -0300
Subject: check timeout when doing a query to /keys to add an exchange

---
 .../taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx
index 0c8336e69..6dbdf4c30 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx
@@ -47,8 +47,15 @@ export function ExchangeAddPage({ onBack }: Props): VNode {
     return (
       <ExchangeSetUrlPage
         onCancel={onBack}
-        knownExchanges={knownExchanges}
-        onVerify={(url) => queryToSlashKeys(url)}
+        onVerify={async (url) => {
+          const found =
+            knownExchanges.findIndex((e) => e.exchangeBaseUrl === url) !== -1;
+
+          if (found) {
+            throw Error("This exchange is already known");
+          }
+          return queryToSlashKeys(url);
+        }}
         onConfirm={(url) =>
           queryToSlashKeys<TalerConfigResponse>(url)
             .then((config) => {
-- 
cgit v1.2.3

