Skip to content

Commit

Permalink
fix: hide slippage warning when trade is x (#7439)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-toby authored Oct 11, 2023
1 parent d56030a commit 1882b14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/Settings/MenuButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { t, Trans } from '@lingui/macro'
import { Settings } from 'components/Icons/Settings'
import Row from 'components/Row'
import { InterfaceTrade } from 'state/routing/types'
import { isUniswapXTrade } from 'state/routing/utils'
import { useUserSlippageTolerance } from 'state/user/hooks'
import { SlippageTolerance } from 'state/user/types'
import styled from 'styled-components'
Expand Down Expand Up @@ -45,11 +47,11 @@ const IconContainerWithSlippage = styled(IconContainer)<{ displayWarning?: boole
displayWarning ? theme.deprecated_accentWarningSoft : theme.surface2};
`

const ButtonContent = () => {
const ButtonContent = ({ trade }: { trade?: InterfaceTrade }) => {
const [userSlippageTolerance] = useUserSlippageTolerance()
const { formatSlippage } = useFormatter()

if (userSlippageTolerance === SlippageTolerance.Auto) {
if (userSlippageTolerance === SlippageTolerance.Auto || isUniswapXTrade(trade)) {
return (
<IconContainer>
<Icon />
Expand All @@ -73,10 +75,12 @@ export default function MenuButton({
disabled,
onClick,
isActive,
trade,
}: {
disabled: boolean
onClick: () => void
isActive: boolean
trade?: InterfaceTrade
}) {
return (
<Button
Expand All @@ -87,7 +91,7 @@ export default function MenuButton({
data-testid="open-settings-dialog-button"
aria-label={t`Transaction Settings`}
>
<ButtonContent />
<ButtonContent trade={trade} />
</Button>
)
}
7 changes: 6 additions & 1 deletion src/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ export default function SettingsTab({

return (
<Menu ref={node}>
<MenuButton disabled={!isChainSupported || chainId !== connectedChainId} isActive={isOpen} onClick={toggleMenu} />
<MenuButton
disabled={!isChainSupported || chainId !== connectedChainId}
isActive={isOpen}
onClick={toggleMenu}
trade={trade}
/>
{isOpenDesktop && <MenuFlyout>{Settings}</MenuFlyout>}
{isOpenMobile && (
<Portal>
Expand Down

1 comment on commit 1882b14

@vercel
Copy link

@vercel vercel bot commented on 1882b14 Oct 11, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

interface – ./

interface-git-main-uniswap.vercel.app
interface-uniswap.vercel.app

Please sign in to comment.