chore: remove unused codes

This commit is contained in:
Tristan Yang
2022-12-09 22:05:57 +08:00
parent 73df08fcc7
commit dac1665994
4 changed files with 68 additions and 88 deletions
@@ -16,8 +16,6 @@ interface Props {
const UserContextMenu: FC<Props> = ({ enable = false, uid, cid, visible, hide, children }) => { const UserContextMenu: FC<Props> = ({ enable = false, uid, cid, visible, hide, children }) => {
const { t } = useTranslation("member"); const { t } = useTranslation("member");
const { const {
canCall,
call,
copyEmail, copyEmail,
canCopyEmail, canCopyEmail,
startChat, startChat,
@@ -48,10 +46,6 @@ const UserContextMenu: FC<Props> = ({ enable = false, uid, cid, visible, hide, c
title: t("send_msg"), title: t("send_msg"),
handler: startChat handler: startChat
}, },
canCall && {
title: t("call"),
handler: call
},
canCopyEmail && { canCopyEmail && {
title: t("copy_email"), title: t("copy_email"),
handler: copyEmail handler: copyEmail
+2 -10
View File
@@ -5,17 +5,16 @@ import { useNavigate, useMatch } from "react-router-dom";
import { hideAll } from "tippy.js"; import { hideAll } from "tippy.js";
import { useRemoveMembersMutation } from "../../app/services/channel"; import { useRemoveMembersMutation } from "../../app/services/channel";
import { useLazyDeleteUserQuery } from "../../app/services/user"; import { useLazyDeleteUserQuery } from "../../app/services/user";
import useConfig from "./useConfig"; // import useConfig from "./useConfig";
import useCopy from "./useCopy"; import useCopy from "./useCopy";
import { useAppSelector } from "../../app/store"; import { useAppSelector } from "../../app/store";
import { AgoraConfig } from "../../types/server"; // import { AgoraConfig } from "../../types/server";
interface IProps { interface IProps {
uid?: number; uid?: number;
cid?: number; cid?: number;
} }
const useUserOperation = ({ uid, cid }: IProps) => { const useUserOperation = ({ uid, cid }: IProps) => {
const [passedUid, setPassedUid] = useState<number | undefined>(undefined); const [passedUid, setPassedUid] = useState<number | undefined>(undefined);
const { values: agoraConfig } = useConfig("agora");
const isUserDetailPath = useMatch(`/users/${uid}`); const isUserDetailPath = useMatch(`/users/${uid}`);
const [removeUser, { isSuccess: removeUserSuccess }] = useLazyDeleteUserQuery(); const [removeUser, { isSuccess: removeUserSuccess }] = useLazyDeleteUserQuery();
const [removeInChannel, { isSuccess: removeSuccess }] = useRemoveMembersMutation(); const [removeInChannel, { isSuccess: removeSuccess }] = useRemoveMembersMutation();
@@ -71,10 +70,6 @@ const useUserOperation = ({ uid, cid }: IProps) => {
navigateTo(`/chat/dm/${uid}`); navigateTo(`/chat/dm/${uid}`);
}; };
const call = () => {
toast.success("Coming Soon...");
hideAll();
};
const isAdmin = !!loginUser?.is_admin; const isAdmin = !!loginUser?.is_admin;
const loginUid = loginUser?.uid; const loginUid = loginUser?.uid;
const canDeleteChannel = !!cid && !channel?.is_public && isAdmin; const canDeleteChannel = !!cid && !channel?.is_public && isAdmin;
@@ -83,7 +78,6 @@ const useUserOperation = ({ uid, cid }: IProps) => {
!channel?.is_public && !channel?.is_public &&
(isAdmin || channel?.owner == loginUid) && (isAdmin || channel?.owner == loginUid) &&
uid != channel?.owner; uid != channel?.owner;
const canCall: boolean = (agoraConfig as AgoraConfig)?.enabled && loginUid != uid;
const canRemove: boolean = isAdmin && loginUid != uid && !cid && uid !== 1; const canRemove: boolean = isAdmin && loginUid != uid && !cid && uid !== 1;
return { return {
@@ -95,8 +89,6 @@ const useUserOperation = ({ uid, cid }: IProps) => {
canRemoveFromChannel, canRemoveFromChannel,
canCopyEmail: !!user?.email, canCopyEmail: !!user?.email,
copyEmail, copyEmail,
canCall,
call
}; };
}; };
export default useUserOperation; export default useUserOperation;
+2 -8
View File
@@ -98,7 +98,6 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
context="channel" context="channel"
dropFiles={dropFiles} dropFiles={dropFiles}
aside={ aside={
<>
<ul className="tools"> <ul className="tools">
{(agoraConfig as AgoraConfig)?.enabled && ( {(agoraConfig as AgoraConfig)?.enabled && (
<li className="tool"> <li className="tool">
@@ -144,7 +143,6 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
</Tooltip> </Tooltip>
</li> </li>
</ul> </ul>
</>
} }
header={ header={
<StyledHeader className="head"> <StyledHeader className="head">
@@ -156,9 +154,7 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
</StyledHeader> </StyledHeader>
} }
users={ users={
membersVisible ? ( <StyledUsers className={membersVisible ? "flex" : "hidden"}>
<>
<StyledUsers>
{addVisible && ( {addVisible && (
<div className="add" onClick={toggleAddVisible}> <div className="add" onClick={toggleAddVisible}>
<img className="icon" src={addIcon} /> <img className="icon" src={addIcon} />
@@ -179,8 +175,6 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
); );
})} })}
</StyledUsers> </StyledUsers>
</>
) : null
} }
> >
<StyledChannelChat id={`VOCECHAT_FEED_channel_${cid}`}> <StyledChannelChat id={`VOCECHAT_FEED_channel_${cid}`}>
@@ -220,4 +214,4 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
</> </>
); );
} }
export default memo(ChannelChat); export default memo(ChannelChat, (prev, next) => prev.cid == next.cid);
+1 -1
View File
@@ -48,7 +48,7 @@ export const StyledNotification = styled.div`
} }
`; `;
export const StyledUsers = styled.div` export const StyledUsers = styled.div`
display: flex; /* display: flex; */
flex-direction: column; flex-direction: column;
gap: 5px; gap: 5px;
/* todo */ /* todo */