import classNames from 'classnames'; import React from 'react'; import { FormattedMessage, FormattedNumber, defineMessages } from 'react-intl'; import { getSettings } from 'soapbox/actions/settings'; import Avatar from 'soapbox/components/avatar'; import DisplayName from 'soapbox/components/display-name'; import Permalink from 'soapbox/components/permalink'; import RelativeTimestamp from 'soapbox/components/relative_timestamp'; import { Text } from 'soapbox/components/ui'; import ActionButton from 'soapbox/features/ui/components/action-button'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; const getAccount = makeGetAccount(); interface IAccountCard { id: string, } const messages = defineMessages({ today: { id: 'account.today', defaultMessage: 'Today' }, yesterday: { id: 'account.yesterday', defaultMessage: 'Yesterday' }, days: { id: 'account.days', defaultMessage: 'Days' }, }); const AccountCard: React.FC = ({ id }) => { const me = useAppSelector((state) => state.me); const account = useAppSelector((state) => getAccount(state, id)); const autoPlayGif = useAppSelector((state) => getSettings(state).get('autoPlayGif')); if (!account) return null; const followedBy = me !== account.id && account.relationship?.followed_by; const ago = React.useMemo(() => { const date = new Date(account.last_status_at).valueOf(); const today = new Date().valueOf(); const diffInDays = Math.floor((today - date) / 1000 / 60 / 60 / 24); return diffInDays; }, [account]); return (
{followedBy &&
}

') && 'empty')} dangerouslySetInnerHTML={{ __html: account.note_emojified }} />
{account.last_status_at === null ? : { (ago < 1) && } { (ago >= 1 && ago < 2) && } { ago >= 2 && <>{ ago } } }
); }; export default AccountCard;