Skip to content

Commit

Permalink
fix: mf-5104 hide contact adding button if it's added (#10518)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill committed Aug 20, 2023
1 parent 29b77db commit 40ff71f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { memo, useCallback } from 'react'
import { Box, Typography, useTheme, type BoxProps } from '@mui/material'
import { Icons } from '@masknet/icons'
import { MaskTextField, makeStyles } from '@masknet/theme'
import { type NetworkPluginID } from '@masknet/shared-base'
import { openWindow } from '@masknet/shared-base-ui'
import { ExplorerResolver } from '@masknet/web3-providers'
import { MaskTextField, makeStyles } from '@masknet/theme'
import { useChainContext } from '@masknet/web3-hooks-base'
import type { NetworkPluginID } from '@masknet/shared-base'
import { ExplorerResolver } from '@masknet/web3-providers'
import { isSameAddress } from '@masknet/web3-shared-base'
import { Box, Typography, useTheme, type BoxProps } from '@mui/material'
import { memo, useCallback, useMemo } from 'react'
import { useI18N } from '../../../../utils/index.js'
import { ContactsContext } from '../../hook/useContactsContext.js'
import { AddContactModal } from '../../modals/modals.js'
Expand Down Expand Up @@ -78,6 +79,8 @@ const AddContactInputPanel = memo(function AddContactInputPanel({ isManage, ...p
address,
userInput,
setUserInput,
contacts,
wallets,
inputValidationMessage: addressValidationMessage,
inputWarningMessage,
} = ContactsContext.useContainer()
Expand All @@ -93,7 +96,12 @@ const AddContactInputPanel = memo(function AddContactInputPanel({ isManage, ...p
})
}, [address, userInput])

const addable = !addressValidationMessage && (address || userInput)
const isAdded = useMemo(
() => [...contacts, ...wallets].some((x) => isSameAddress(address, x.address)),
[contacts, wallets, address],
)

const addable = !addressValidationMessage && (address || userInput) && !isAdded
const shouldShowAddress = !!address && address !== userInput

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const AccountRender = memo<AccountRenderProps>(function AccountRender({ p
? profile.name
: profile.identity
return detail ? (
<DetailAccount userId={_userID} icon={profile.platform} />
<DetailAccount userId={_userID} platform={profile.platform} />
) : (
<Account userId={_userID} icon={profile.platform} />
)
Expand Down

0 comments on commit 40ff71f

Please sign in to comment.