Refactor VerificationBadge

next-feed
Alex Gleason 2022-04-05 12:32:41 -05:00
rodzic fdb298c417
commit efe5670147
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -1,10 +1,9 @@
import classNames from 'classnames';
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { useIntl, defineMessages } from 'react-intl';
import { useSelector } from 'react-redux';
import Icon from 'soapbox/components/ui/icon/icon';
import { useSoapboxConfig } from 'soapbox/hooks';
const messages = defineMessages({
verified: { id: 'account.verified', defaultMessage: 'Verified Account' },
@ -14,12 +13,12 @@ interface IVerificationBadge {
className?: string,
}
const VerificationBadge = ({ className }: IVerificationBadge) => {
const VerificationBadge: React.FC<IVerificationBadge> = ({ className }) => {
const intl = useIntl();
const soapboxConfig = useSoapboxConfig();
// Prefer a custom icon if found
const customIcon = useSelector((state: ImmutableMap<string, any>) => state.getIn(['soapbox', 'verifiedIcon']));
const icon = customIcon || require('icons/verified.svg');
const icon = soapboxConfig.verifiedIcon || require('icons/verified.svg');
// Render component based on file extension
const Element = icon.endsWith('.svg') ? Icon : 'img';