import emojify from '@/utils/emojify' import { Entity, MegalodonInterface } from 'megalodon' import { MouseEventHandler, useEffect, useState } from 'react' import { FaEllipsisVertical } from 'react-icons/fa6' import { FormattedMessage } from 'react-intl' import Timeline from './profile/Timeline' import Followings from './profile/Followings' import Followers from './profile/Followers' import { findLink } from '@/utils/statusParser' import { Account } from '@/db' import { Avatar, Button, IconButton, List, ListItem, Popover, PopoverContent, PopoverHandler, Tab, TabPanel, Tabs, TabsBody, TabsHeader } from '@material-tailwind/react' type Props = { client: MegalodonInterface account: Account user_id: string openMedia: (media: Entity.Attachment) => void } export default function Profile(props: Props) { const [user, setUser] = useState(null) const [relationship, setRelationship] = useState(null) const [popoverDetail, setPopoverDetail] = useState(false) 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) setPopoverDetail(false) }} >
@{user.acct}
{user.fields.map((data, index) => (
{data.name}
))}
)}
) }