From 4eb664f36b4ef3d685e9bffb97cbbf7ecba3ca3e Mon Sep 17 00:00:00 2001 From: pavanjoshi914 Date: Thu, 15 Feb 2024 20:55:15 +0530 Subject: [PATCH 1/4] feat: fix callback url show proper error messages --- src/app/screens/LNURLChannel/index.tsx | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/screens/LNURLChannel/index.tsx b/src/app/screens/LNURLChannel/index.tsx index 65be12b859..8c927de92a 100644 --- a/src/app/screens/LNURLChannel/index.tsx +++ b/src/app/screens/LNURLChannel/index.tsx @@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import ScreenHeader from "~/app/components/ScreenHeader"; import toast from "~/app/components/Toast"; +import Checkbox from "~/app/components/form/Checkbox"; import { useNavigationState } from "~/app/hooks/useNavigationState"; import { USER_REJECTED_ERROR } from "~/common/constants"; import api from "~/common/lib/api"; @@ -30,6 +31,7 @@ function LNURLChannel() { const [loadingConfirm, setLoadingConfirm] = useState(false); const [successMessage, setSuccessMessage] = useState(""); + const [isPrivateChannel, setIsPrivateChannel] = useState(false); async function confirm() { try { @@ -54,6 +56,7 @@ function LNURLChannel() { params: { k1: details.k1, remoteid: nodeId, + private: isPrivateChannel ? 1 : 0, }, adapter: fetchAdapter, }); @@ -73,8 +76,12 @@ function LNURLChannel() { msg.reply(callbackResponse?.data); } } catch (e) { - console.error(e); - if (e instanceof Error) toast.error(`Error: ${e.message}`); + if (axios.isAxiosError(e)) { + const error = + (e.response?.data as { reason?: string })?.reason || e.message; + console.error(e); + toast.error(`Error: ${error}`); + } } finally { setLoadingConfirm(false); } @@ -115,6 +122,22 @@ function LNURLChannel() { heading={`${t("content_message.heading")}:`} content={uri} /> +
+ { + setIsPrivateChannel(event.target.checked); + }} + /> + +
Date: Mon, 19 Feb 2024 12:14:48 +0530 Subject: [PATCH 2/4] chore: improvements --- src/app/screens/LNURLChannel/index.tsx | 10 ++++++---- src/i18n/locales/en/translation.json | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/screens/LNURLChannel/index.tsx b/src/app/screens/LNURLChannel/index.tsx index 8c927de92a..bee49b97c4 100644 --- a/src/app/screens/LNURLChannel/index.tsx +++ b/src/app/screens/LNURLChannel/index.tsx @@ -76,11 +76,13 @@ function LNURLChannel() { msg.reply(callbackResponse?.data); } } catch (e) { + console.error(e); if (axios.isAxiosError(e)) { const error = (e.response?.data as { reason?: string })?.reason || e.message; - console.error(e); toast.error(`Error: ${error}`); + } else if (e instanceof Error) { + toast.error(`Error: ${e.message}`); } } finally { setLoadingConfirm(false); @@ -124,8 +126,8 @@ function LNURLChannel() { />
{ setIsPrivateChannel(event.target.checked); @@ -135,7 +137,7 @@ function LNURLChannel() { htmlFor="is_private_channel" className="cursor-pointer ml-2 block text-sm text-gray-900 font-medium dark:text-white" > - Open a private channel? + {t("is_private_channel.label")}
diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 144b6e7e6b..47c8acca01 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -705,6 +705,9 @@ "content_message": { "heading": "Request a channel from the node" }, + "is_private_channel": { + "label": "Open a private channel?" + }, "success": "Channel request sent successfully to {{name}}" }, "lnurlwithdraw": { From 33691b2efd0b1ecb53063e7fb3c2a1f176d29dbb Mon Sep 17 00:00:00 2001 From: pavanjoshi914 Date: Mon, 19 Feb 2024 15:44:21 +0530 Subject: [PATCH 3/4] chore: namings --- src/app/screens/LNURLChannel/index.tsx | 12 ++++++------ src/i18n/locales/en/translation.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/screens/LNURLChannel/index.tsx b/src/app/screens/LNURLChannel/index.tsx index bee49b97c4..d99c01bb32 100644 --- a/src/app/screens/LNURLChannel/index.tsx +++ b/src/app/screens/LNURLChannel/index.tsx @@ -31,7 +31,7 @@ function LNURLChannel() { const [loadingConfirm, setLoadingConfirm] = useState(false); const [successMessage, setSuccessMessage] = useState(""); - const [isPrivateChannel, setIsPrivateChannel] = useState(false); + const [privateChannel, setPrivateChannel] = useState(false); async function confirm() { try { @@ -56,7 +56,7 @@ function LNURLChannel() { params: { k1: details.k1, remoteid: nodeId, - private: isPrivateChannel ? 1 : 0, + private: privateChannel ? 1 : 0, }, adapter: fetchAdapter, }); @@ -128,16 +128,16 @@ function LNURLChannel() { { - setIsPrivateChannel(event.target.checked); + setPrivateChannel(event.target.checked); }} /> diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 47c8acca01..70ea0b04ea 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -705,7 +705,7 @@ "content_message": { "heading": "Request a channel from the node" }, - "is_private_channel": { + "private_channel": { "label": "Open a private channel?" }, "success": "Channel request sent successfully to {{name}}" From 3a786ec17f5236d7bb54f83fab68e71e0de80fd1 Mon Sep 17 00:00:00 2001 From: pavanjoshi914 Date: Fri, 23 Feb 2024 11:20:42 +0530 Subject: [PATCH 4/4] chore: cleanup --- src/app/screens/LNURLChannel/index.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/app/screens/LNURLChannel/index.tsx b/src/app/screens/LNURLChannel/index.tsx index d99c01bb32..928659b873 100644 --- a/src/app/screens/LNURLChannel/index.tsx +++ b/src/app/screens/LNURLChannel/index.tsx @@ -44,9 +44,6 @@ function LNURLChannel() { const nodeId = infoResponse.node.pubkey; if (!nodeId) { - toast.error( - `No nodeId available. Your account might not support channel requests` - ); throw new Error( `No nodeId available. Your account might not support channel requests` );