From 321fc450f105a789b209a0b63b1e92d06c38353e Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Fri, 17 Jan 2025 15:48:22 +0700 Subject: [PATCH 1/4] fix: use browser router in http mode --- frontend/src/App.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index a6b4094e..23f44e30 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,8 @@ -import { RouterProvider, createHashRouter } from "react-router-dom"; +import { + RouterProvider, + createBrowserRouter, + createHashRouter, +} from "react-router-dom"; import { ThemeProvider } from "src/components/ui/theme-provider"; @@ -6,8 +10,10 @@ import { Toaster } from "src/components/ui/toaster"; import { TouchProvider } from "src/components/ui/tooltip"; import { useInfo } from "src/hooks/useInfo"; import routes from "src/routes.tsx"; +import { isHttpMode } from "src/utils/isHttpMode"; -const router = createHashRouter(routes); +const createRouterFunc = isHttpMode() ? createBrowserRouter : createHashRouter; +const router = createRouterFunc(routes); function App() { const { data: info } = useInfo(); From ec6a8367ffedf822ce35e64b330cffb1e88a1cb2 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Fri, 17 Jan 2025 15:51:56 +0700 Subject: [PATCH 2/4] fix: update links to not use hash router --- frontend/src/components/SuggestedAppData.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/SuggestedAppData.tsx b/frontend/src/components/SuggestedAppData.tsx index a2ba6e7a..b3ea24e2 100644 --- a/frontend/src/components/SuggestedAppData.tsx +++ b/frontend/src/components/SuggestedAppData.tsx @@ -417,7 +417,7 @@ export const suggestedApps: SuggestedApp[] = [
  • 4. Click{" "} Connect to BTCPay Server @@ -492,7 +492,7 @@ export const suggestedApps: SuggestedApp[] = [
  • 4. Click{" "} Connect to LNbits @@ -569,7 +569,7 @@ export const suggestedApps: SuggestedApp[] = [
  • 4. Click{" "} Connect to Coracle @@ -639,7 +639,7 @@ export const suggestedApps: SuggestedApp[] = [
  • 3. Click{" "} Connect to Nostter From 50057ba473aa119bdf5f0b1e7073aeccf4320f41 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Fri, 17 Jan 2025 15:56:29 +0700 Subject: [PATCH 3/4] fix: add redirect from hash router url --- frontend/src/main.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index a5485e4b..cf3ea5dc 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -1,11 +1,18 @@ import React from "react"; import ReactDOM from "react-dom/client"; import App from "src/App.tsx"; -import "src/index.css"; import "src/fonts.css"; +import "src/index.css"; +import { isHttpMode } from "src/utils/isHttpMode"; -ReactDOM.createRoot(document.getElementById("root")!).render( - - - -); +// redirect hash router links to browser router links +// TODO: remove after 2026-01-01 +if (isHttpMode() && window.location.href.indexOf("/#/") > -1) { + window.location.href = window.location.href.replace("/#/", "/"); +} else { + ReactDOM.createRoot(document.getElementById("root")!).render( + + + + ); +} From fe726f9886b0091cf2114234b3f9b526405d6ffc Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Sat, 18 Jan 2025 17:11:52 +0700 Subject: [PATCH 4/4] fix: return nostrWalletConnectUrl in nwc connection success event and message --- frontend/src/screens/apps/AppCreated.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/screens/apps/AppCreated.tsx b/frontend/src/screens/apps/AppCreated.tsx index e329c906..ba3d8e52 100644 --- a/frontend/src/screens/apps/AppCreated.tsx +++ b/frontend/src/screens/apps/AppCreated.tsx @@ -61,7 +61,11 @@ function AppCreatedInternal() { } // dispatch a success event which can be listened to by the opener or by the app that embedded the webview // this gives those apps the chance to know the user has enabled the connection - const nwcEvent = new CustomEvent("nwc:success", { detail: {} }); + const nwcEvent = new CustomEvent("nwc:success", { + detail: { + nostrWalletConnectUrl: pairingUri, + }, + }); window.dispatchEvent(nwcEvent); // notify the opener of the successful connection @@ -69,12 +73,12 @@ function AppCreatedInternal() { window.opener.postMessage( { type: "nwc:success", - payload: { success: true }, + nostrWalletConnectUrl: pairingUri, }, "*" ); } - }, [appstoreApp]); + }, [appstoreApp, pairingUri]); if (!createAppResponse) { return ;