import emojify from '@/utils/emojify' import { Avatar, Button, CustomFlowbiteTheme, Dropdown, Flowbite, Tabs } from 'flowbite-react' import { Entity, MegalodonInterface } from 'megalodon' import { MouseEventHandler, useEffect, useState } from 'react' import { FaEllipsisVertical } from 'react-icons/fa6' import { FormattedMessage, useIntl } from 'react-intl' import Timeline from './profile/Timeline' import Followings from './profile/Followings' import Followers from './profile/Followers' import { findLink } from '@/utils/statusParser' type Props = { client: MegalodonInterface user_id: string openMedia: (media: Entity.Attachment) => void } const customTheme: CustomFlowbiteTheme = { tab: { tablist: { tabitem: { base: 'flex items-center justify-center p-4 rounded-t-lg text-sm font-medium first:ml-0 disabled:cursor-not-allowed disabled:text-gray-400 disabled:dark:text-gray-500' } } } } export default function Profile(props: Props) { const [user, setUser] = useState(null) const [relationship, setRelationship] = useState(null) const { formatMessage } = useIntl() useEffect(() => { const f = async () => { if (props.user_id) { const res = await props.client.getAccount(props.user_id) setUser(res.data) const rel = await props.client.getRelationship(props.user_id) setRelationship(rel.data) } } f() }, [props.user_id, props.client]) const follow = async (id: string) => { const rel = await props.client.followAccount(id) setRelationship(rel.data) } const unfollow = async (id: string) => { const rel = await props.client.unfollowAccount(id) setRelationship(rel.data) } const openOriginal = async (url: string) => { global.ipc.invoke('open-browser', url) } const profileClicked: MouseEventHandler = async e => { const url = findLink(e.target as HTMLElement, 'profile') if (url) { global.ipc.invoke('open-browser', url) e.preventDefault() e.stopPropagation() } } return (
{user && relationship && ( <>
header image
{relationship.following ? ( ) : ( )} ( )} > openOriginal(user.url)}>
@{user.acct}
{user.fields.map((data, index) => (
{data.name}
))}
)}
) }