Skip to content

Commit

Permalink
Merge pull request #395 from reservoirprotocol/jaden/grwth-3523-deep-…
Browse files Browse the repository at this point in the history
…link-chains-on-portfolio

Jaden/grwth 3523 deep link chains on portfolio
  • Loading branch information
JadenDurnford authored Nov 30, 2023
2 parents ef11cf9 + 7e62646 commit 39e4c6f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
15 changes: 5 additions & 10 deletions components/common/ChainToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ const ChainToggle: FC = () => {
key={supportedChain.id}
css={{ py: '$3', px: '$1', display: 'flex', gap: '$2' }}
onClick={() => {
const newUrl = router.asPath.replace(
chain.routePrefix,
supportedChain.routePrefix
)
router.query.chain = supportedChain.routePrefix
router.push(router, undefined, { shallow: true })

router.replace(newUrl, undefined, { scroll: false })
switchCurrentChain(supportedChain.id)
}}
>
Expand Down Expand Up @@ -139,12 +136,10 @@ const ChainToggle: FC = () => {
value={chainOption.name}
disabled={chainOption.name === chain.name}
onClick={() => {
const newUrl = router.asPath.replace(
chain.routePrefix,
chainOption.routePrefix
)
router.query.chain = chainOption.routePrefix
router.push(router, undefined, { shallow: true })

switchCurrentChain(chainOption.id)
router.replace(newUrl, undefined, { scroll: false })
}}
>
<Box
Expand Down
5 changes: 2 additions & 3 deletions components/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const Navbar = () => {
const isMobile = useMediaQuery({ query: '(max-width: 960px' })
const isMounted = useMounted()
const { routePrefix } = useMarketplaceChain()
const { address } = useAccount();

const { address } = useAccount()

let searchRef = useRef<HTMLInputElement>(null)

Expand Down Expand Up @@ -246,7 +245,7 @@ const Navbar = () => {
</HoverCard.Root>
</Box>
{isConnected && (
<Link href={`/portfolio/${address || ''}`}>
<Link href={`/portfolio/${address || ''}?chain=${routePrefix}`}>
<Box css={{ mr: '$2' }}>
<NavItem>Portfolio</NavItem>
</Box>
Expand Down
6 changes: 6 additions & 0 deletions context/ChainContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const ChainContextProvider: FC<any> = ({ children }) => {
(chain) => chain.id === +savedChainId
)
}

if (!router.query.chain && selectedChain) {
router.query.chain = selectedChain.routePrefix
router.push(router, undefined, { shallow: true })
}

const id = selectedChain?.id || DefaultChain.id
setGlobalChainId(id)
localStorage.setItem('reservoir.chainId', `${id}`)
Expand Down
2 changes: 1 addition & 1 deletion pages/portfolio/[[...address]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const IndexPage: NextPage = () => {
router.query.tab = tabValue
router.push(router, undefined, { shallow: true })
}
}, [tabValue])
}, [tabValue, router])

if (!isMounted) {
return null
Expand Down

1 comment on commit 39e4c6f

@vercel
Copy link

@vercel vercel bot commented on 39e4c6f Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.