2023-11-04 10:14:00 +01:00
|
|
|
import { Entity } from 'megalodon'
|
|
|
|
import { FaUserPlus } from 'react-icons/fa6'
|
|
|
|
import { FormattedMessage, useIntl } from 'react-intl'
|
|
|
|
import emojify from '@/utils/emojify'
|
2024-01-09 13:30:05 +01:00
|
|
|
import { Avatar } from '@material-tailwind/react'
|
2024-01-14 15:30:21 +01:00
|
|
|
import { useRouter } from 'next/router'
|
2023-11-04 10:14:00 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
notification: Entity.Notification
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Follow(props: Props) {
|
|
|
|
const { formatMessage } = useIntl()
|
2024-01-14 15:30:21 +01:00
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
const openUser = (id: string) => {
|
|
|
|
router.push({ query: { id: router.query.id, timeline: router.query.timeline, user_id: id, detail: true } })
|
|
|
|
}
|
2023-11-04 10:14:00 +01:00
|
|
|
|
|
|
|
return (
|
2024-03-14 17:12:19 +01:00
|
|
|
<div className="border-b border-gray-200 dark:border-gray-800 mr-2 py-1">
|
2023-11-04 10:14:00 +01:00
|
|
|
<div className="flex items-center">
|
|
|
|
<div style={{ width: '56px' }}>
|
|
|
|
<FaUserPlus className="text-blue-600 w-4 mr-2 ml-auto" />
|
|
|
|
</div>
|
2024-03-14 17:12:19 +01:00
|
|
|
<div
|
|
|
|
className="cursor-pointer text-gray-950 dark:text-gray-300"
|
|
|
|
style={{ width: 'calc(100% - 56px)' }}
|
|
|
|
onClick={() => openUser(props.notification.account.id)}
|
|
|
|
>
|
2023-11-04 10:14:00 +01:00
|
|
|
<span
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: emojify(
|
|
|
|
formatMessage(
|
|
|
|
{
|
|
|
|
id: actionId(props.notification)
|
|
|
|
},
|
|
|
|
{ user: props.notification.account.username }
|
|
|
|
),
|
|
|
|
props.notification.account.emojis
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex">
|
2024-01-14 15:30:21 +01:00
|
|
|
<div className="p-2 cursor-pointer" style={{ width: '56px' }}>
|
|
|
|
<Avatar
|
|
|
|
src={props.notification.account.avatar}
|
|
|
|
onClick={() => openUser(props.notification.account.id)}
|
|
|
|
variant="rounded"
|
|
|
|
style={{ width: '40px', height: '40px' }}
|
2024-01-30 16:51:36 +01:00
|
|
|
alt={formatMessage({ id: 'timeline.status.avatar' }, { user: props.notification.account.username })}
|
2024-01-14 15:30:21 +01:00
|
|
|
/>
|
2023-11-04 10:14:00 +01:00
|
|
|
</div>
|
|
|
|
<div style={{ width: 'calc(100% - 56px)' }}>
|
2024-01-14 15:30:21 +01:00
|
|
|
<div className="flex cursor-pointer" onClick={() => openUser(props.notification.account.id)}>
|
2023-11-04 10:14:00 +01:00
|
|
|
<span
|
2024-03-14 17:12:19 +01:00
|
|
|
className="text-gray-950 dark:text-gray-300 text-ellipsis break-all overflow-hidden"
|
2023-11-04 10:14:00 +01:00
|
|
|
dangerouslySetInnerHTML={{ __html: emojify(props.notification.account.display_name, props.notification.account.emojis) }}
|
|
|
|
></span>
|
2024-03-14 17:12:19 +01:00
|
|
|
<span className="text-gray-600 dark:text-gray-500 text-ellipsis break-all overflow-hidden">
|
|
|
|
@{props.notification.account.acct}
|
|
|
|
</span>
|
2023-11-04 10:14:00 +01:00
|
|
|
</div>
|
2024-03-14 17:12:19 +01:00
|
|
|
<div className="text-gray-600 dark:text-gray-500">
|
2023-11-04 10:14:00 +01:00
|
|
|
<FormattedMessage id="notification.follow.followers" values={{ num: props.notification.account.followers_count }} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const actionId = (notification: Entity.Notification) => {
|
|
|
|
if (notification.type === 'follow_request') {
|
|
|
|
return 'notification.follow_request.body'
|
|
|
|
} else {
|
|
|
|
return 'notification.follow.body'
|
|
|
|
}
|
|
|
|
}
|