diff --git a/src/App.tsx b/src/App.tsx index 3c83468..5b2ec0f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,29 @@ - +import { useEffect } from "react"; import Navbar from "./Components/Shared/Navbar/Navbar"; import ExplorePage from "./Components/ExplorePage/ExplorePage"; import ModalsContainer from "./Components/Shared/ModalsContainer/ModalsContainer"; +import { useAppDispatch, useAppSelector } from './utils/hooks'; +import { connectWallet } from './redux/features/wallet.slice'; function App() { + const { isWalletConnected, webln } = useAppSelector(state => ({ + isWalletConnected: state.wallet.isConnected, + webln: state.wallet.provider, + })); + + const dispatch = useAppDispatch(); + + useEffect(() => { + if(typeof window.webln != "undefined") { + window.webln.enable().then((res: any) => { + dispatch(connectWallet(window.webln)); + console.log("called:webln.enable()", res); + }).catch((err: any) => { + console.log("error:webln.enable()", err); + }); + } + }, []); + return