import { X, Plus } from "@styled-icons/boxicons-regular"; import { PhoneCall, Envelope, UserX } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; import { User } from "revolt.js"; import styles from "./Friend.module.scss"; import classNames from "classnames"; import { useTriggerEvents } from "preact-context-menu"; import { Text } from "preact-i18n"; import { IconButton } from "@revoltchat/ui"; import { stopPropagation } from "../../lib/stopPropagation"; import { voiceState } from "../../lib/vortex/VoiceState"; import { useIntermediate } from "../../context/intermediate/Intermediate"; import UserIcon from "../../components/common/user/UserIcon"; import UserStatus from "../../components/common/user/UserStatus"; import { modalController } from "../../controllers/modals/ModalController"; interface Props { user: User; } export const Friend = observer(({ user }: Props) => { const history = useHistory(); const { openScreen } = useIntermediate(); const actions: Children[] = []; let subtext: Children = null; if (user.relationship === "Friend") { subtext = ; actions.push( <> stopPropagation( ev, user .openDM() .then(voiceState.connect) .then((x) => history.push(`/channel/${x._id}`)), ) }> stopPropagation( ev, user .openDM() .then((channel) => history.push(`/channel/${channel._id}`), ), ) }> , ); } if (user.relationship === "Incoming") { actions.push( stopPropagation(ev, user.addFriend())}> , ); subtext = ; } if (user.relationship === "Outgoing") { subtext = ; } if ( user.relationship === "Friend" || user.relationship === "Outgoing" || user.relationship === "Incoming" ) { actions.push( stopPropagation( ev, user.relationship === "Friend" ? openScreen({ id: "special_prompt", type: "unfriend_user", target: user, }) : user.removeFriend(), ) }> , ); } if (user.relationship === "Blocked") { actions.push( stopPropagation(ev, user.unblockUser())}> , ); } return (
modalController.push({ type: "user_profile", user_id: user._id, }) } {...useTriggerEvents("Menu", { user: user._id, })}>
{user.username} {subtext && {subtext}}
{actions}
); });