import { RightOutlined } from "@ant-design/icons"; import { Button, Divider, Drawer } from "antd"; import { t } from "i18next"; import { forwardRef, ForwardRefRenderFunction, memo } from "react"; import { modal } from "@/AntdGlobalComp"; import OIMAvatar from "@/components/OIMAvatar"; import SettingRow from "@/components/SettingRow"; import { OverlayVisibleHandle, useOverlayVisible } from "@/hooks/useOverlayVisible"; import { IMSDK } from "@/layout/MainContentWrap"; import { useContactStore } from "@/store/contact"; import { feedbackToast } from "@/utils/common"; import { emit } from "@/utils/events"; import { useConversationStore } from "@/store"; // export interface SingleSettingProps {} const SingleSetting: ForwardRefRenderFunction = ( _, ref, ) => { const currentConversation = useConversationStore( (state) => state.currentConversation, ); const isBlack = useContactStore((state) => state.blackList).some( (black) => currentConversation?.userID === black.userID, ); const isFriend = useContactStore((state) => state.friendList).some( (friend) => currentConversation?.userID === friend.userID, ); const { isOverlayOpen, closeOverlay } = useOverlayVisible(ref); const updateBlack = async () => { if (!currentConversation) return; const execFunc = async () => { try { isBlack ? await IMSDK.removeBlack(currentConversation?.userID) : await IMSDK.addBlack({ toUserID: currentConversation?.userID, }); } catch (error) { feedbackToast({ error, msg: t("toast.updateBlackStateFailed") }); } }; if (!isBlack) { modal.confirm({ title: t("placeholder.moveBlacklist"), content: (
{t("toast.confirmMoveBlacklist")}
{t("placeholder.willFilterThisUserMessage")}
), onOk: execFunc, }); } else { await execFunc(); } }; const tryUnfriend = () => { if (!currentConversation) return; modal.confirm({ title: t("placeholder.unfriend"), content: t("toast.confirmUnfriend"), onOk: async () => { try { await IMSDK.deleteFriend(currentConversation.userID); } catch (error) { feedbackToast({ error, msg: t("toast.unfriendFailed") }); } }, }); }; const openUserCard = () => { emit("OPEN_USER_CARD", { userID: currentConversation?.userID }); }; return (
{currentConversation?.showName}
{isFriend && (
)} ); }; export default memo(forwardRef(SingleSetting));