From 51cd31a421e68ac784caa8c185fa9647991aff7a Mon Sep 17 00:00:00 2001 From: Matt <90358481+xbtmatt@users.noreply.github.com> Date: Sat, 22 Jun 2024 10:32:57 -0700 Subject: [PATCH] [ECO-1823] Fix infinite connect wallet bug by removing manual autoconnect (#111) Co-authored-by: matt Co-authored-by: alnoki <43892045+alnoki@users.noreply.github.com> --- .../frontend/src/context/providers.tsx | 2 +- .../wallet-context/ConnectWalletContext.tsx | 34 ++----------------- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/src/typescript/frontend/src/context/providers.tsx b/src/typescript/frontend/src/context/providers.tsx index 0d5d00ce1..f77f91d62 100644 --- a/src/typescript/frontend/src/context/providers.tsx +++ b/src/typescript/frontend/src/context/providers.tsx @@ -60,7 +60,7 @@ const ThemedApp: React.FC<{ children: React.ReactNode }> = ({ children }) => { - + diff --git a/src/typescript/frontend/src/context/wallet-context/ConnectWalletContext.tsx b/src/typescript/frontend/src/context/wallet-context/ConnectWalletContext.tsx index 013da8c44..b0e21c617 100644 --- a/src/typescript/frontend/src/context/wallet-context/ConnectWalletContext.tsx +++ b/src/typescript/frontend/src/context/wallet-context/ConnectWalletContext.tsx @@ -1,5 +1,5 @@ -import { useWallet, type WalletName } from "@aptos-labs/wallet-adapter-react"; -import { createContext, type PropsWithChildren, useContext, useEffect, useState } from "react"; +import { useWallet } from "@aptos-labs/wallet-adapter-react"; +import { createContext, type PropsWithChildren, useContext, useState } from "react"; import { toast } from "react-toastify"; import { BaseModal } from "components/modal/BaseModal"; @@ -16,35 +16,6 @@ const WalletItemClassName = "transition-all hover:text-ec-blue " + "text-black group"; -let t: NodeJS.Timeout | null = null; -const AutoConnect = () => { - const { account, connect } = useWallet(); - useEffect(() => { - if (!account && localStorage.getItem("AptosWalletName")) { - const f = async () => { - try { - connect(localStorage.getItem("AptosWalletName") as WalletName); - } catch (error) { - if (t) { - clearInterval(t); - } - } - }; - f(); - t = setInterval(f, 100); - } else if (t) { - clearInterval(t); - } - return () => { - if (t) { - clearInterval(t); - } - }; - }, [account]); /* eslint-disable-line react-hooks/exhaustive-deps */ - - return null; -}; - export function ConnectWalletContextProvider({ children }: PropsWithChildren) { const { connect, wallet: activeWallet, wallets, disconnect } = useWallet(); const [open, setOpen] = useState(false); @@ -56,7 +27,6 @@ export function ConnectWalletContextProvider({ children }: PropsWithChildren) { return ( - {children}