From dac1665994f21bb5ea35a2227c0524acf158eb8d Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Fri, 9 Dec 2022 22:05:57 +0800 Subject: [PATCH] chore: remove unused codes --- src/common/component/User/ContextMenu.tsx | 6 - src/common/hook/useUserOperation.ts | 12 +- src/routes/chat/ChannelChat/index.tsx | 136 +++++++++++----------- src/routes/chat/ChannelChat/styled.tsx | 2 +- 4 files changed, 68 insertions(+), 88 deletions(-) diff --git a/src/common/component/User/ContextMenu.tsx b/src/common/component/User/ContextMenu.tsx index b5351424..8224cabc 100644 --- a/src/common/component/User/ContextMenu.tsx +++ b/src/common/component/User/ContextMenu.tsx @@ -16,8 +16,6 @@ interface Props { const UserContextMenu: FC = ({ enable = false, uid, cid, visible, hide, children }) => { const { t } = useTranslation("member"); const { - canCall, - call, copyEmail, canCopyEmail, startChat, @@ -48,10 +46,6 @@ const UserContextMenu: FC = ({ enable = false, uid, cid, visible, hide, c title: t("send_msg"), handler: startChat }, - canCall && { - title: t("call"), - handler: call - }, canCopyEmail && { title: t("copy_email"), handler: copyEmail diff --git a/src/common/hook/useUserOperation.ts b/src/common/hook/useUserOperation.ts index c2b91a39..4e86b2d5 100644 --- a/src/common/hook/useUserOperation.ts +++ b/src/common/hook/useUserOperation.ts @@ -5,17 +5,16 @@ import { useNavigate, useMatch } from "react-router-dom"; import { hideAll } from "tippy.js"; import { useRemoveMembersMutation } from "../../app/services/channel"; import { useLazyDeleteUserQuery } from "../../app/services/user"; -import useConfig from "./useConfig"; +// import useConfig from "./useConfig"; import useCopy from "./useCopy"; import { useAppSelector } from "../../app/store"; -import { AgoraConfig } from "../../types/server"; +// import { AgoraConfig } from "../../types/server"; interface IProps { uid?: number; cid?: number; } const useUserOperation = ({ uid, cid }: IProps) => { const [passedUid, setPassedUid] = useState(undefined); - const { values: agoraConfig } = useConfig("agora"); const isUserDetailPath = useMatch(`/users/${uid}`); const [removeUser, { isSuccess: removeUserSuccess }] = useLazyDeleteUserQuery(); const [removeInChannel, { isSuccess: removeSuccess }] = useRemoveMembersMutation(); @@ -71,10 +70,6 @@ const useUserOperation = ({ uid, cid }: IProps) => { navigateTo(`/chat/dm/${uid}`); }; - const call = () => { - toast.success("Coming Soon..."); - hideAll(); - }; const isAdmin = !!loginUser?.is_admin; const loginUid = loginUser?.uid; const canDeleteChannel = !!cid && !channel?.is_public && isAdmin; @@ -83,7 +78,6 @@ const useUserOperation = ({ uid, cid }: IProps) => { !channel?.is_public && (isAdmin || channel?.owner == loginUid) && uid != channel?.owner; - const canCall: boolean = (agoraConfig as AgoraConfig)?.enabled && loginUid != uid; const canRemove: boolean = isAdmin && loginUid != uid && !cid && uid !== 1; return { @@ -95,8 +89,6 @@ const useUserOperation = ({ uid, cid }: IProps) => { canRemoveFromChannel, canCopyEmail: !!user?.email, copyEmail, - canCall, - call }; }; export default useUserOperation; diff --git a/src/routes/chat/ChannelChat/index.tsx b/src/routes/chat/ChannelChat/index.tsx index 1a491478..f26e510d 100644 --- a/src/routes/chat/ChannelChat/index.tsx +++ b/src/routes/chat/ChannelChat/index.tsx @@ -98,53 +98,51 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) { context="channel" dropFiles={dropFiles} aside={ - <> -
    - {(agoraConfig as AgoraConfig)?.enabled && ( -
  • - - - -
  • - )} - - } - > -
  • 0 ? "badge" : ""}`} data-count={pinCount}> - -
  • -
    -
    - - } - > -
  • - -
  • -
    -
    -
  • - - +
      + {(agoraConfig as AgoraConfig)?.enabled && ( +
    • + +
    • -
    - + )} + + } + > +
  • 0 ? "badge" : ""}`} data-count={pinCount}> + +
  • + + + + } + > +
  • + +
  • +
    +
    +
  • + + + +
  • +
} header={ @@ -156,31 +154,27 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) { } users={ - membersVisible ? ( - <> - - {addVisible && ( -
- -
{t("add_channel_members")}
-
- )} - {memberIds.map((uid: number) => { - return ( - - ); - })} -
- - ) : null + + {addVisible && ( +
+ +
{t("add_channel_members")}
+
+ )} + {memberIds.map((uid: number) => { + return ( + + ); + })} +
} > @@ -220,4 +214,4 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) { ); } -export default memo(ChannelChat); +export default memo(ChannelChat, (prev, next) => prev.cid == next.cid); diff --git a/src/routes/chat/ChannelChat/styled.tsx b/src/routes/chat/ChannelChat/styled.tsx index 40465a74..202e291f 100644 --- a/src/routes/chat/ChannelChat/styled.tsx +++ b/src/routes/chat/ChannelChat/styled.tsx @@ -48,7 +48,7 @@ export const StyledNotification = styled.div` } `; export const StyledUsers = styled.div` - display: flex; + /* display: flex; */ flex-direction: column; gap: 5px; /* todo */