From 61efae8e57b6fa232501d76d43b591dc8f0b7b55 Mon Sep 17 00:00:00 2001 From: Tony Giorgio Date: Mon, 21 Aug 2023 13:47:09 -0500 Subject: [PATCH] Ask user to open callback URI after NWC --- src/routes/settings/Connections.tsx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/routes/settings/Connections.tsx b/src/routes/settings/Connections.tsx index 08da779..2319d68 100644 --- a/src/routes/settings/Connections.tsx +++ b/src/routes/settings/Connections.tsx @@ -46,6 +46,8 @@ function Nwc() { const [dialogOpen, setDialogOpen] = createSignal(!!queryName); const [createLoading, setCreateLoading] = createSignal(false); const [error, setError] = createSignal(""); + const [callbackDialogOpen, setCallbackDialogOpen] = createSignal(false); + const [callbackUri, setCallbackUri] = createSignal(null); async function createConnection() { try { @@ -67,17 +69,18 @@ function Nwc() { refetch(); } + setFormName(""); + setDialogOpen(false); + const callbackUriScheme = getCallbackQueryParam(); if (callbackUriScheme) { const fullURI = profile.nwc_uri.replace( "nostr+walletconnect://", `${getCallbackQueryParam()}://` ); - window.open(fullURI, "_blank"); + setCallbackUri(fullURI); + setCallbackDialogOpen(true); } - - setFormName(""); - setDialogOpen(false); } catch (e) { setError(eify(e).message); console.error(e); @@ -86,6 +89,13 @@ function Nwc() { } } + function openCallbackUri() { + if (callbackUri()) { + window.open(callbackUri() as string, "_blank"); + setCallbackDialogOpen(false); + } + } + async function toggleEnabled(profile: NwcProfile) { try { await state.mutiny_wallet?.edit_nwc_profile({ @@ -222,6 +232,14 @@ function Nwc() { {i18n.t("settings.connections.create_connection")} + +

Click the button below to open in the app.

+ +
); }