Skip to content

Commit

Permalink
fix: repeat calls in disconnect fctn
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv authored and fracek committed May 17, 2023
1 parent b5b3459 commit 26c1310
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions packages/core/src/providers/starknet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,11 @@ function useStarknetManager({
localStorage.removeItem('lastUsedConnector')
}
if (!state.connector) return
state.connector.disconnect().then(
() => {
dispatch({ type: 'set_account', account: undefined })
dispatch({
type: 'set_provider',
provider: userDefaultProvider ? userDefaultProvider : customDefaultProvider,
})
dispatch({ type: 'set_connector', connector: undefined })
state.connector?.removeEventListener(handleAccountChanged)
if (autoConnect) {
localStorage.removeItem('lastUsedConnector')
}
},
(err) => {
console.error(err)
dispatch({ type: 'set_error', error: new ConnectorNotFoundError() })
}
)
state.connector.removeEventListener(handleAccountChanged)
state.connector.disconnect().catch((err) => {
console.error(err)
dispatch({ type: 'set_error', error: new ConnectorNotFoundError() })
})
}, [autoConnect, state.connector])

const handleAccountChanged = useCallback(() => {
Expand Down

0 comments on commit 26c1310

Please sign in to comment.