Commit bf16dfa0 authored by lynn's avatar lynn Committed by GitHub

fix: fix twitter links (#4868)

* fix twitter links

* fix
parent 910e86d6
...@@ -119,9 +119,7 @@ export default function ChartSection({ ...@@ -119,9 +119,7 @@ export default function ChartSection({
{!warning && <VerifiedIcon size="16px" />} {!warning && <VerifiedIcon size="16px" />}
</TokenNameCell> </TokenNameCell>
<TokenActions> <TokenActions>
{token.name && token.symbol && token.address && ( {token.name && token.symbol && token.address && <ShareButton token={token} isNative={!!nativeCurrency} />}
<ShareButton tokenName={token.name} tokenSymbol={token.symbol} tokenAddress={token.address} />
)}
{useFavoriteTokensFlag() === FavoriteTokensVariant.Enabled && ( {useFavoriteTokensFlag() === FavoriteTokensVariant.Enabled && (
<ClickFavorited onClick={toggleFavorite}> <ClickFavorited onClick={toggleFavorite}>
<FavoriteIcon isFavorited={isFavorited} /> <FavoriteIcon isFavorited={isFavorited} />
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { NATIVE_CHAIN_ID } from 'constants/tokens'
import { SingleTokenData } from 'graphql/data/Token'
import { useOnClickOutside } from 'hooks/useOnClickOutside' import { useOnClickOutside } from 'hooks/useOnClickOutside'
import { useRef } from 'react' import { useRef } from 'react'
import { Twitter } from 'react-feather' import { Twitter } from 'react-feather'
...@@ -62,9 +64,8 @@ const ShareAction = styled.div` ...@@ -62,9 +64,8 @@ const ShareAction = styled.div`
` `
interface TokenInfo { interface TokenInfo {
tokenName: string token: NonNullable<SingleTokenData>
tokenSymbol: string isNative: boolean
tokenAddress: string
} }
export default function ShareButton(tokenInfo: TokenInfo) { export default function ShareButton(tokenInfo: TokenInfo) {
...@@ -75,11 +76,12 @@ export default function ShareButton(tokenInfo: TokenInfo) { ...@@ -75,11 +76,12 @@ export default function ShareButton(tokenInfo: TokenInfo) {
useOnClickOutside(node, open ? toggleShare : undefined) useOnClickOutside(node, open ? toggleShare : undefined)
const positionX = (window.screen.width - TWITTER_WIDTH) / 2 const positionX = (window.screen.width - TWITTER_WIDTH) / 2
const positionY = (window.screen.height - TWITTER_HEIGHT) / 2 const positionY = (window.screen.height - TWITTER_HEIGHT) / 2
const tokenAddress = tokenInfo.isNative ? NATIVE_CHAIN_ID : tokenInfo.token.address
const shareTweet = () => { const shareTweet = () => {
toggleShare() toggleShare()
window.open( window.open(
`https://twitter.com/intent/tweet?text=Check%20out%20${tokenInfo.tokenName}%20(${tokenInfo.tokenSymbol})%20https://app.uniswap.org/%23/tokens/${tokenInfo.tokenAddress}%20via%20@uniswap`, `https://twitter.com/intent/tweet?text=Check%20out%20${tokenInfo.token.name}%20(${tokenInfo.token.symbol})%20https://app.uniswap.org/%23/tokens/${tokenInfo.token.chain}/${tokenAddress}%20via%20@uniswap`,
'newwindow', 'newwindow',
`left=${positionX}, top=${positionY}, width=${TWITTER_WIDTH}, height=${TWITTER_HEIGHT}` `left=${positionX}, top=${positionY}, width=${TWITTER_WIDTH}, height=${TWITTER_HEIGHT}`
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment