Skip to content

Commit

Permalink
Merge pull request #487 from OasisDEX/dev
Browse files Browse the repository at this point in the history
Release 2.0.4
  • Loading branch information
peculiarity authored Sep 23, 2021
2 parents ac38293 + d8b4079 commit 735fe71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions components/connectWallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,6 @@ function autoConnect(
let firstTime = true

const subscription = web3Context$.subscribe(async (web3Context) => {
if (web3Context.status === 'error' && web3Context.error instanceof UnsupportedChainIdError) {
web3Context.deactivate()
}

try {
const serialized = localStorage.getItem(AUTO_CONNECT)
if (firstTime && web3Context.status === 'notConnected' && serialized) {
Expand Down Expand Up @@ -508,10 +504,17 @@ async function connectReadonly(web3Context: Web3ContextNotConnected) {
}

export function WithConnection({ children }: WithChildren) {
const { replace } = useRedirect()
const { web3Context$ } = useAppContext()
const web3Context = useObservable(web3Context$)

useEffect(() => {
if (web3Context?.status === 'error' && web3Context.error instanceof UnsupportedChainIdError) {
disconnect(web3Context)
redirectState$.next(window.location.pathname)
replace(`/connect`)
}

if (web3Context && web3Context.status === 'connectedReadonly') {
redirectState$.next(window.location.pathname)
}
Expand All @@ -526,11 +529,19 @@ export function WithWalletConnection({ children }: WithChildren) {
const { replace } = useRedirect()
const { web3Context$ } = useAppContext()
const web3Context = useObservable(web3Context$)

useEffect(() => {
if (web3Context?.status === 'error' && web3Context.error instanceof UnsupportedChainIdError) {
disconnect(web3Context)
redirectState$.next(window.location.pathname)
replace(`/connect`)
}

if (web3Context?.status === 'connectedReadonly') {
redirectState$.next(window.location.pathname)
replace(`/connect`)
}

if (web3Context?.status === 'notConnected') {
redirectState$.next(window.location.pathname)
autoConnect(web3Context$, getNetworkId(), () => replace(`/connect`))
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
"moving-into-vault": "Moving into Vault",
"moving-out-vault": "Moving out of Vault",
"multiple": "Multiple",
"metamask-unsupported-network": "You are on an unsupported network. Please switch to Mainnet.",
"net-value": "Net Value",
"nav": {
"about": "About",
Expand Down

0 comments on commit 735fe71

Please sign in to comment.