From 9b52b4423fec87c10ed72619c66a9f15675d55b6 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Fri, 2 Sep 2022 21:28:37 +0800 Subject: [PATCH] chore: remove comments --- src/common/component/Profile/index.tsx | 4 ++-- src/common/component/RequireAuth.tsx | 3 +-- src/common/hook/useStreaming/chat.handler.ts | 1 - src/routes/chat/DMList/NavItem.tsx | 1 - src/routes/chat/LoadMore.tsx | 1 - src/routes/chat/SessionList/ContextMenu.tsx | 1 - src/routes/chat/SessionList/Session.tsx | 1 - src/routes/home/index.tsx | 2 -- src/routes/setting/ProfileBasicEditModal.tsx | 1 - src/routes/settingChannel/DeleteConfirmModal.tsx | 2 -- src/routes/users/index.tsx | 12 +++--------- 11 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/common/component/Profile/index.tsx b/src/common/component/Profile/index.tsx index aff5e301..f9aa9c30 100644 --- a/src/common/component/Profile/index.tsx +++ b/src/common/component/Profile/index.tsx @@ -1,4 +1,4 @@ -import { FC } from "react"; +import { FC, memo } from "react"; import { NavLink } from "react-router-dom"; import Tippy from "@tippyjs/react"; import IconMessage from "../../../assets/icons/message.svg"; @@ -110,4 +110,4 @@ const Profile: FC = ({ uid, type = "embed", cid }) => { ); }; -export default Profile; +export default memo(Profile); diff --git a/src/common/component/RequireAuth.tsx b/src/common/component/RequireAuth.tsx index 49b2762d..7ec11944 100644 --- a/src/common/component/RequireAuth.tsx +++ b/src/common/component/RequireAuth.tsx @@ -13,14 +13,12 @@ const GuestAllows = GuestRoutes.map((path) => { return { path }; }); const RequireAuth: FC = ({ children, redirectTo = "/login" }) => { - // GuestRoutes const location = useLocation(); const matchs = matchRoutes(GuestAllows, location); const allowGuest = matchs ? !!matchs[0].pathname : false; const { data: loginConfig, isLoading: fetchingLoginConfig } = useGetLoginConfigQuery(); const { isLoading: checkingInitial } = useGetInitializedQuery(); const { token, guest, initialized } = useAppSelector((store) => store.authData); - // console.log("authhhhh", allowGuest); // 初始化和login配置检查 if (checkingInitial || fetchingLoginConfig) return null; @@ -30,6 +28,7 @@ const RequireAuth: FC = ({ children, redirectTo = "/login" }) => { if (loginConfig?.guest && !token && allowGuest) return ; // 登陆者是guest,并且不允许访问 if (token && guest && !allowGuest) return ; + // console.log("authhhhh", allowGuest, token, guest); return token ? children : ; }; diff --git a/src/common/hook/useStreaming/chat.handler.ts b/src/common/hook/useStreaming/chat.handler.ts index 7aca4779..2ff75abf 100644 --- a/src/common/hook/useStreaming/chat.handler.ts +++ b/src/common/hook/useStreaming/chat.handler.ts @@ -63,7 +63,6 @@ const handler = (data: ChatEvent, dispatch: AppDispatch, currState: CurrentState // 如果是自己发的消息,就是已读 dispatch(addMessage({ mid, read, ...common })); // 未推送完 or 不是自己发的消息 - // console.log("curr state", ready, loginUid, common.from_uid); // if (!ready || loginUid != common.from_uid) { dispatch( appendMessage({ diff --git a/src/routes/chat/DMList/NavItem.tsx b/src/routes/chat/DMList/NavItem.tsx index 8b129021..ca70c603 100644 --- a/src/routes/chat/DMList/NavItem.tsx +++ b/src/routes/chat/DMList/NavItem.tsx @@ -41,7 +41,6 @@ const NavItem: FC = ({ uid, mid = 0, unreads, setFiles }) => { accept: [NativeTypes.FILE], drop({ dataTransfer }) { if (dataTransfer.files.length) { - // console.log(files, rest); setFiles([...dataTransfer.files]); navigate(`/chat/dm/${uid}`); // 重置 diff --git a/src/routes/chat/LoadMore.tsx b/src/routes/chat/LoadMore.tsx index 15aed449..995596eb 100644 --- a/src/routes/chat/LoadMore.tsx +++ b/src/routes/chat/LoadMore.tsx @@ -23,7 +23,6 @@ const LoadMore: FC = ({ pullUp = null }) => { // const currEle = entry.target; if (intersecting && pullUp) { // load more - // console.log("inview"); pullUp(); } }); diff --git a/src/routes/chat/SessionList/ContextMenu.tsx b/src/routes/chat/SessionList/ContextMenu.tsx index ebbe0240..d0626489 100644 --- a/src/routes/chat/SessionList/ContextMenu.tsx +++ b/src/routes/chat/SessionList/ContextMenu.tsx @@ -49,7 +49,6 @@ const SessionContextMenu: FC = ({ }; const handleReadAll = () => { - // console.log("last mid", mids, lastMid); if (mid) { const param = context == "user" ? { users: [{ uid: +id, mid }] } : { groups: [{ gid: +id, mid }] }; diff --git a/src/routes/chat/SessionList/Session.tsx b/src/routes/chat/SessionList/Session.tsx index 55cb74bb..04a2ca74 100644 --- a/src/routes/chat/SessionList/Session.tsx +++ b/src/routes/chat/SessionList/Session.tsx @@ -35,7 +35,6 @@ const Session: FC = ({ accept: [NativeTypes.FILE], drop({ files }) { if (files.length) { - // console.log(files, rest); const filesData = files.map((file) => { const { size, type, name } = file; const url = URL.createObjectURL(file); diff --git a/src/routes/home/index.tsx b/src/routes/home/index.tsx index c2c7e40d..2153ff5f 100644 --- a/src/routes/home/index.tsx +++ b/src/routes/home/index.tsx @@ -30,7 +30,6 @@ export default function HomePage() { } = useAppSelector((store) => { return { ui: store.ui, - loginUid: store.authData.user?.uid, guest: store.authData.guest }; @@ -87,7 +86,6 @@ export default function HomePage() { - {/*
*/} )} diff --git a/src/routes/setting/ProfileBasicEditModal.tsx b/src/routes/setting/ProfileBasicEditModal.tsx index 2c81e06f..e80fb5cd 100644 --- a/src/routes/setting/ProfileBasicEditModal.tsx +++ b/src/routes/setting/ProfileBasicEditModal.tsx @@ -41,7 +41,6 @@ const ProfileBasicEditModal: FC = ({ closeModal }) => { const [input, setInput] = useState(value); - // const dispatch = useDispatch(); const [update, { isLoading, isSuccess }] = useUpdateInfoMutation(); const handleChange = (evt: ChangeEvent) => { setInput(evt.target.value); diff --git a/src/routes/settingChannel/DeleteConfirmModal.tsx b/src/routes/settingChannel/DeleteConfirmModal.tsx index 43c6bd8d..6ddbf672 100644 --- a/src/routes/settingChannel/DeleteConfirmModal.tsx +++ b/src/routes/settingChannel/DeleteConfirmModal.tsx @@ -13,7 +13,6 @@ interface Props { const DeleteConfirmModal: FC = ({ id, closeModal }) => { const navigateTo = useNavigate(); - // const pathMatched = useMatch(`/chat/channel/${id}`); const [deleteChannel, { isLoading, isSuccess }] = useLazyRemoveChannelQuery(); const handleDelete = () => { deleteChannel(id); @@ -44,7 +43,6 @@ const DeleteConfirmModal: FC = ({ id, closeModal }) => { } - // className="animate__animated animate__fadeInDown animate__faster" > ); diff --git a/src/routes/users/index.tsx b/src/routes/users/index.tsx index f545f696..f3e9f565 100644 --- a/src/routes/users/index.tsx +++ b/src/routes/users/index.tsx @@ -40,15 +40,9 @@ export default function UsersPage() { - {user_id ? ( -
- -
- ) : ( -
- -
- )} +
+ {user_id ? : } +
); }