1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 09:23:21 +01:00

UX: Create selector for blockie preference (#20577)

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
This commit is contained in:
David Walsh 2023-08-31 08:53:22 -05:00 committed by GitHub
parent c15226325e
commit 53f585b68e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View File

@ -14,7 +14,7 @@ import {
TextVariant,
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { getMetaMaskAccountsOrdered } from '../../../selectors';
import { getMetaMaskAccountsOrdered, getUseBlockie } from '../../../selectors';
import {
clearAccountDetails,
hideWarning,
@ -41,7 +41,7 @@ export const AccountDetails = ({ address }) => {
const dispatch = useDispatch();
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
const useBlockie = useSelector((state) => state.metamask.useBlockie);
const useBlockie = useSelector(getUseBlockie);
const accounts = useSelector(getMetaMaskAccountsOrdered);
const { name } = accounts.find((account) => account.address === address);
const [showHoldToReveal, setShowHoldToReveal] = useState(false);

View File

@ -44,6 +44,7 @@ import {
MetaMetricsEventName,
} from '../../../../shared/constants/metametrics';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import { getUseBlockie } from '../../../selectors';
const MAXIMUM_CURRENCY_DECIMALS = 3;
const MAXIMUM_CHARACTERS_WITHOUT_TOOLTIP = 17;
@ -82,7 +83,7 @@ export const AccountListItem = ({
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
const [accountListItemMenuElement, setAccountListItemMenuElement] =
useState();
const useBlockie = useSelector((state) => state.metamask.useBlockie);
const useBlockie = useSelector(getUseBlockie);
const setAccountListItemMenuRef = (ref) => {
setAccountListItemMenuElement(ref);

View File

@ -24,6 +24,7 @@ import {
TextColor,
TextVariant,
} from '../../../helpers/constants/design-system';
import { getUseBlockie } from '../../../selectors';
import { shortenAddress } from '../../../helpers/utils/util';
export const AccountPicker = ({
@ -33,7 +34,7 @@ export const AccountPicker = ({
disabled,
showAddress = false,
}) => {
const useBlockie = useSelector((state) => state.metamask.useBlockie);
const useBlockie = useSelector(getUseBlockie);
const shortenedAddress = shortenAddress(toChecksumHexAddress(address));
return (

View File

@ -1137,6 +1137,16 @@ export function getUseNftDetection(state) {
return Boolean(state.metamask.useNftDetection);
}
/**
* To get the useBlockie flag which determines whether we show blockies or Jazzicons
*
* @param {*} state
* @returns Boolean
*/
export function getUseBlockie(state) {
return Boolean(state.metamask.useBlockie);
}
/**
* To get the openSeaEnabled flag which determines whether we use OpenSea's API
*