Skip to content

Commit ee17d6a

Browse files
authored
Merge pull request #155 from suiet/fix/autoconnect
Fix/autoconnect
2 parents b9b58f7 + b44478c commit ee17d6a

File tree

3 files changed

+3144
-2796
lines changed

3 files changed

+3144
-2796
lines changed

packages/kit/src/components/WalletProvider.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export const WalletProvider = (props: WalletProviderProps) => {
110110
const disconnect = useCallback(async () => {
111111
ensureCallable(walletAdapter, status);
112112
const adapter = walletAdapter as IWalletAdapter;
113+
113114
// try to clear listeners
114115
if (isNonEmptyArray(walletOffListeners.current)) {
115116
walletOffListeners.current.forEach(off => {
@@ -121,6 +122,12 @@ export const WalletProvider = (props: WalletProviderProps) => {
121122
})
122123
walletOffListeners.current = [] // empty array
123124
}
125+
126+
// clear storage for last connected wallet
127+
// if users disconnect wallet manually
128+
const storage = new Storage()
129+
storage.removeItem(StorageKey.LAST_CONNECT_WALLET_NAME)
130+
124131
try {
125132
// disconnect is an optional action for wallet
126133
if (adapter.hasFeature(FeatureName.STANDARD__DISCONNECT)) {

packages/kit/src/hooks/useAutoConnect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function useAutoConnect(
2525
if (!lastConnectedWalletName) return
2626

2727
if (allAvailableWallets.find(item => item.name == lastConnectedWalletName)) {
28-
console.log('auto connect to wallet:', lastConnectedWalletName)
28+
// console.log('auto connect to wallet:', lastConnectedWalletName)
2929
select(lastConnectedWalletName)
3030
.then(() => {
3131
init.current = true

0 commit comments

Comments
 (0)