Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lnurl channel #3046

Merged
merged 8 commits into from
Feb 23, 2024
27 changes: 25 additions & 2 deletions src/app/screens/LNURLChannel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -30,6 +31,7 @@ function LNURLChannel() {

const [loadingConfirm, setLoadingConfirm] = useState(false);
const [successMessage, setSuccessMessage] = useState("");
const [isPrivateChannel, setIsPrivateChannel] = useState(false);

async function confirm() {
try {
Expand All @@ -54,6 +56,7 @@ function LNURLChannel() {
params: {
k1: details.k1,
remoteid: nodeId,
private: isPrivateChannel ? 1 : 0,
},
adapter: fetchAdapter,
});
Expand All @@ -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)) {
pavanjoshi914 marked this conversation as resolved.
Show resolved Hide resolved
const error =
(e.response?.data as { reason?: string })?.reason || e.message;
console.error(e);
toast.error(`Error: ${error}`);
}
} finally {
setLoadingConfirm(false);
}
Expand Down Expand Up @@ -115,6 +122,22 @@ function LNURLChannel() {
heading={`${t("content_message.heading")}:`}
content={uri}
/>
<div className="flex">
<Checkbox
id="is_private_channel"
name="private channel checkbox"
pavanjoshi914 marked this conversation as resolved.
Show resolved Hide resolved
checked={isPrivateChannel}
onChange={(event) => {
setIsPrivateChannel(event.target.checked);
}}
/>
<label
htmlFor="is_private_channel"
className="cursor-pointer ml-2 block text-sm text-gray-900 font-medium dark:text-white"
>
Open a private channel?
pavanjoshi914 marked this conversation as resolved.
Show resolved Hide resolved
</label>
</div>
</div>
<ConfirmOrCancel
disabled={loadingConfirm || !uri}
Expand Down
Loading