Refactor Account favicon into a button component, gets rid of console error

merge-requests/1249/merge
Alex Gleason 2022-04-21 18:27:16 -05:00
rodzic eecc46cbdc
commit 4047f796d1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 21 dodań i 4 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link, useHistory } from 'react-router-dom';
import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper';
import VerificationBadge from 'soapbox/components/verification_badge';
@ -13,6 +13,25 @@ import { Avatar, HStack, IconButton, Text } from './ui';
import type { Account as AccountEntity } from 'soapbox/types/entities';
interface IInstanceFavicon {
account: AccountEntity,
}
const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account }) => {
const history = useHistory();
const handleClick: React.MouseEventHandler = (e) => {
e.stopPropagation();
history.push(`/timeline/${account.domain}`);
};
return (
<button className='w-4 h-4 flex-none' onClick={handleClick}>
<img src={account.favicon} alt='' title={account.domain} className='w-full max-h-full' />
</button>
);
};
interface IProfilePopper {
condition: boolean,
wrapper: (children: any) => React.ReactElement<any, any>
@ -172,9 +191,7 @@ const Account = ({
<Text theme='muted' size='sm' truncate>@{username}</Text>
{account.favicon && (
<Link to={`/timeline/${account.domain}`} className='w-4 h-4 flex-none' onClick={e => e.stopPropagation()}>
<img src={account.favicon} alt='' title={account.domain} className='w-full max-h-full' />
</Link>
<InstanceFavicon account={account} />
)}
{(timestamp) ? (