From 48c979b728743aab02fcc4f42b766715e1bc6627 Mon Sep 17 00:00:00 2001 From: ankushKun Date: Fri, 24 May 2024 18:15:27 +0530 Subject: [PATCH] fix active address --- next_app/src/components/layout.tsx | 2 +- next_app/src/pages/codecell.tsx | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/next_app/src/components/layout.tsx b/next_app/src/components/layout.tsx index 8634802..f9e3ac5 100644 --- a/next_app/src/components/layout.tsx +++ b/next_app/src/components/layout.tsx @@ -596,7 +596,7 @@ export default function Layout() { return ( <> - BetterIDEa | {globalState.activeProject || "Home"} + {`BetterIDEa ${globalState.activeProject && ("| " + globalState.activeProject)}`} diff --git a/next_app/src/pages/codecell.tsx b/next_app/src/pages/codecell.tsx index 23eb2e3..68adc90 100644 --- a/next_app/src/pages/codecell.tsx +++ b/next_app/src/pages/codecell.tsx @@ -30,6 +30,7 @@ export default function CodeCell() { console.log("autoconn", autoconnect) useEffect(() => { + if (searchParams.size > 0) { if (searchParams.has("code")) { setCode(searchParams.get("code") as string) @@ -52,14 +53,19 @@ export default function CodeCell() { } } - if (autoconnect && !mounted) { - window.arweaveWallet.getActiveAddress().then((addr: string) => { - connectHandler(); - setMounted(true); - }).catch(() => { - setAutoconnect(false); - }); + async function run() { + if (autoconnect && !mounted) { + try { + const addr = await window.arweaveWallet.getActiveAddress() + setWalletAddr(addr); + setAutoconnect(true); + } + catch { + setAutoconnect(false); + } + } } + run() }, [searchParams, autoconnect, mounted]) async function connectHandler() {