Skip to content

Commit 94a121d

Browse files
authored
fix: navigation hidden (#23)
1 parent a83e168 commit 94a121d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

pages/_app.tsx

+18-12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function App({ Component, pageProps }) {
2828
const { account, provider, chainId } = state
2929
const isSupportCurrentNetwork = SUPPORT_NETWORKS.includes(chainId)
3030

31-
const [autoLoginState, actions] = useAsync(async() => {
31+
const [autoLoginState, actions] = useAsync(async () => {
3232
if (!sigInLocal || !accountInLocal) return
3333
const cachedProvider = await createProvider(undefined, (id) => dispatch({ type: "SET_CHAIN_ID", chainId: id }))
3434
if (!cachedProvider) return
@@ -37,14 +37,18 @@ function App({ Component, pageProps }) {
3737
const signer = web3Provider.getSigner()
3838
const address = await signer.getAddress()
3939
const network = await web3Provider.getNetwork()
40-
if (address !== accountInLocal) return
41-
dispatch({
42-
type: 'SET_WEB3_PROVIDER',
43-
provider: cachedProvider,
44-
web3Provider,
45-
account: address,
46-
chainId: network.chainId,
47-
})
40+
if (address !== accountInLocal) {
41+
removeLocalAccount()
42+
removeLocalSig()
43+
} else {
44+
dispatch({
45+
type: 'SET_WEB3_PROVIDER',
46+
provider: cachedProvider,
47+
web3Provider,
48+
account: address,
49+
chainId: network.chainId,
50+
})
51+
}
4852
})
4953

5054
useMountEffect(actions.execute)
@@ -66,7 +70,7 @@ function App({ Component, pageProps }) {
6670
return { state, dispatch }
6771
}, [state, dispatch])
6872

69-
const connectWallet = useCallback(async function() {
73+
const connectWallet = useCallback(async function () {
7074
const provider = await createProvider(undefined, (id) => dispatch({ type: "SET_CHAIN_ID", chainId: id }))
7175
if (provider.chainId !== '0x13881') {
7276
await switchNetwork(provider)
@@ -102,7 +106,7 @@ function App({ Component, pageProps }) {
102106
})
103107
}, [])
104108

105-
const disconnectWallet = async() => {
109+
const disconnectWallet = async () => {
106110
dispatch({
107111
type: 'SET_WEB3_PROVIDER',
108112
provider: undefined,
@@ -156,7 +160,6 @@ function App({ Component, pageProps }) {
156160
{renderActionButton()}
157161
</div>
158162
</div>
159-
160163
{
161164
sigInLocal && account && isSupportCurrentNetwork &&
162165
<div className="absolute top-8 right-8 text-right fixed">
@@ -212,6 +215,9 @@ function App({ Component, pageProps }) {
212215
</Menu>
213216
</div>
214217
}
218+
<div className="flex justify-around">
219+
<Navigation/>
220+
</div>
215221
</nav>
216222
<Web3Context.Provider value={web3ContextValue}>
217223
<Component {...pageProps} />

0 commit comments

Comments
 (0)