diff --git a/src/components/CreateButton.tsx b/src/components/CreateButton.tsx index 4855fe7c..d262268c 100644 --- a/src/components/CreateButton.tsx +++ b/src/components/CreateButton.tsx @@ -160,7 +160,7 @@ export const CreateButton = () => { (() => { return new Promise(async (resolve, reject) => { const timeout = setTimeout( - () => reject("timeout"), + () => reject(t("timeout")), 5_000, ); @@ -169,7 +169,6 @@ export const CreateButton = () => { lnurl(), Number(receiveAmount()), ); - clearTimeout(timeout); resolve(res); } catch (e) { log.warn( @@ -177,24 +176,32 @@ export const CreateButton = () => { e, ); reject(e); + } finally { + clearTimeout(timeout); } }); })(), (() => { return new Promise(async (resolve, reject) => { + const timeout = setTimeout( + () => reject(t("timeout")), + 5_000, + ); + try { - resolve( - await fetchBip353( - lnurl(), - Number(receiveAmount()), - ), + const res = await fetchBip353( + lnurl(), + Number(receiveAmount()), ); + resolve(res); } catch (e) { log.warn( "Fetching invoice from BIP-353 failed:", e, ); reject(e); + } finally { + clearTimeout(timeout); } }); })(), diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index c49aa4b5..1a2a63cf 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -211,6 +211,7 @@ const dict = { block: "block", logs_scan_progress: "Scan progress {{ value }}%", accept: "Accept", + timeout: "Timeout", }, de: { language: "Deutsch", @@ -433,6 +434,7 @@ const dict = { block: "Block", logs_scan_progress: "Scan-Fortschritt {{ value }}%", accept: "Akzeptieren", + timeout: "Timeout", }, es: { language: "Español", @@ -654,6 +656,7 @@ const dict = { block: "bloque", logs_scan_progress: "Progreso del escaneo {{ value }}%", accept: "Aceptar", + timeout: "timeout", }, zh: { language: "中文", @@ -848,6 +851,7 @@ const dict = { block: "块", logs_scan_progress: "扫描进度{{ value }}%", accept: "接受", + timeout: "超时", }, };