Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v1.385.0 #4982

Merged
merged 8 commits into from
Jul 26, 2023
4 changes: 1 addition & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export const App = () => {
const translate = useTranslate()
const showWelcomeModal = useSelector(selectShowWelcomeModal)
const showConsentBanner = useSelector(selectShowConsentBanner)
const {
nativeOnboard: { isOpen: isNativeOnboardOpen, open: openNativeOnboard },
} = useModal()
const { isOpen: isNativeOnboardOpen, open: openNativeOnboard } = useModal('nativeOnboard')

useEffect(() => {
if (shouldUpdate && !toast.isActive(updateId)) {
Expand Down
42 changes: 18 additions & 24 deletions src/Routes/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LanguageTypeEnum } from 'constants/LanguageTypeEnum'
import { useEffect, useMemo, useState } from 'react'
import type { Location } from 'history'
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import { useDispatch } from 'react-redux'
import { matchPath, Redirect, Route, Switch, useLocation } from 'react-router-dom'
import { Layout } from 'components/Layout/Layout'
Expand All @@ -16,16 +17,9 @@ import { selectSelectedLocale } from 'state/slices/selectors'
import { useAppSelector } from 'state/store'

import { PrivateRoute } from './PrivateRoute'

function useLocationBackground() {
const location = useLocation<{ background: any }>()
const background = location.state && location.state.background
return { background, location }
}

export const Routes = () => {
export const Routes = memo(() => {
const dispatch = useDispatch()
const { background, location } = useLocationBackground()
const location = useLocation<{ background: Location }>()
const { connectDemo, state } = useWallet()
const { appRoutes } = useBrowserRouter()
const hasWallet = Boolean(state.walletInfo?.deviceId) || state.isLoadingLocalWallet
Expand Down Expand Up @@ -87,20 +81,20 @@ export const Routes = () => {
[appRoutes, hasWallet, isUnstableRoute, location],
)

const locationProps = useMemo(() => location.state?.background || location, [location])

const renderRedirect = useCallback(() => {
return shouldRedirectDemoRoute ? (
<Redirect
from='/'
to={matchDemoPath?.params.appRoute ? `/${matchDemoPath.params.appRoute}` : '/dashboard'}
/>
) : null
}, [matchDemoPath?.params.appRoute, shouldRedirectDemoRoute])

return (
<Switch location={background || location}>
<Route path='/demo'>
{() => {
return shouldRedirectDemoRoute ? (
<Redirect
from='/'
to={
matchDemoPath?.params?.appRoute ? `/${matchDemoPath.params.appRoute}` : '/dashboard'
}
/>
) : null
}}
</Route>
<Switch location={locationProps}>
<Route path='/demo'>{renderRedirect}</Route>

<Route path='/connect-wallet'>
<ConnectWallet />
Expand Down Expand Up @@ -131,4 +125,4 @@ export const Routes = () => {
</Layout>
</Switch>
)
}
})
Loading
Loading