reconnect to phantom on each page change
This commit is contained in:
parent
6fff247d02
commit
a1e0e82990
|
@ -116,14 +116,15 @@ export default function useWallet() {
|
|||
actions.reloadOrders()
|
||||
actions.fetchTradeHistory()
|
||||
actions.fetchWalletTokens()
|
||||
notify({
|
||||
title: t('wallet-connected'),
|
||||
description:
|
||||
t('connected-to') +
|
||||
wallet.publicKey.toString().substr(0, 5) +
|
||||
'...' +
|
||||
wallet.publicKey.toString().substr(-5),
|
||||
})
|
||||
|
||||
// notify({
|
||||
// title: t('wallet-connected'),
|
||||
// description:
|
||||
// t('connected-to') +
|
||||
// wallet.publicKey.toString().substr(0, 5) +
|
||||
// '...' +
|
||||
// wallet.publicKey.toString().substr(-5),
|
||||
// })
|
||||
})
|
||||
wallet.on('disconnect', () => {
|
||||
console.log('disconnecting wallet')
|
||||
|
@ -138,16 +139,6 @@ export default function useWallet() {
|
|||
title: t('wallet-disconnected'),
|
||||
})
|
||||
})
|
||||
return () => {
|
||||
if (wallet && wallet.connected) {
|
||||
console.log('DISCONNECTING')
|
||||
|
||||
wallet.disconnect()
|
||||
}
|
||||
setMangoStore((state) => {
|
||||
state.wallet.connected = false
|
||||
})
|
||||
}
|
||||
}, [wallet, setMangoStore])
|
||||
|
||||
useInterval(() => {
|
||||
|
|
|
@ -74,6 +74,12 @@ export default function Account() {
|
|||
setShowNameModal(false)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
// Will either automatically connect to Phantom, or do nothing.
|
||||
// @ts-ignore
|
||||
window.solana.connect({ onlyIfTrusted: true })
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
async function loadUnownedMangoAccount() {
|
||||
try {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useState } from 'react'
|
||||
import { useCallback, useState, useEffect } from 'react'
|
||||
import { CurrencyDollarIcon, LinkIcon } from '@heroicons/react/outline'
|
||||
import useMangoStore from '../stores/useMangoStore'
|
||||
import PageBodyContainer from '../components/PageBodyContainer'
|
||||
|
@ -33,6 +33,12 @@ export default function Borrow() {
|
|||
setShowAccountsModal(false)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
// Will either automatically connect to Phantom, or do nothing.
|
||||
// @ts-ignore
|
||||
window.solana.connect({ onlyIfTrusted: true })
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className={`bg-th-bkg-1 text-th-fgd-1 transition-all`}>
|
||||
<TopBar />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useState } from 'react'
|
||||
import { useState, useEffect } from 'react'
|
||||
import TopBar from '../components/TopBar'
|
||||
import PageBodyContainer from '../components/PageBodyContainer'
|
||||
import StatsTotals from '../components/stats_page/StatsTotals'
|
||||
|
@ -45,6 +45,12 @@ export default function StatsPage() {
|
|||
setActiveTab(tabName)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// Will either automatically connect to Phantom, or do nothing.
|
||||
// @ts-ignore
|
||||
window.solana.connect({ onlyIfTrusted: true })
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className={`bg-th-bkg-1 text-th-fgd-1 transition-all`}>
|
||||
<TopBar />
|
||||
|
|
Loading…
Reference in New Issue