From 0bf167e4e8aea4597e5188dd7895e4398fb6afb9 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Mon, 13 Mar 2023 18:32:06 +0800 Subject: [PATCH] chore: tweaks --- src/common/component/LinkifyText.tsx | 2 +- src/common/component/Message/index.tsx | 3 ++- src/common/hook/usePreload.ts | 5 ++++- src/routes/chat/SessionList/ContextMenu.tsx | 2 +- src/routes/chat/SessionList/index.tsx | 6 +++--- src/routes/home/index.tsx | 2 +- src/routes/settingChannel/Overview.tsx | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/common/component/LinkifyText.tsx b/src/common/component/LinkifyText.tsx index 109acdc4..aaa5ed75 100644 --- a/src/common/component/LinkifyText.tsx +++ b/src/common/component/LinkifyText.tsx @@ -30,7 +30,7 @@ const LinkifyText = ({ url = true, mention = true, mentionTextOnly = false, ment ; }, url: ({ content, attributes: { href: link } }) => { - console.log("attr", link); + // console.log("attr", link); if (!url) return <>{content}; return <> diff --git a/src/common/component/Message/index.tsx b/src/common/component/Message/index.tsx index f12797c4..5442b858 100644 --- a/src/common/component/Message/index.tsx +++ b/src/common/component/Message/index.tsx @@ -63,7 +63,7 @@ const Message: FC = ({ } } }, [mid, read]); - + if (!message) return null; const { reply_mid, from_uid: fromUid, @@ -91,6 +91,7 @@ const Message: FC = ({ const _key = properties?.local_id || mid; const showExpire = (expires_in ?? 0) > 0; return ( +
{ if (isGuest && channelIds.length > 0 && !preloadChannelMsgs) { const tmps = channelIds.filter((cid) => !channelMessageData[cid]); + // console.log("preload", channelIds, tmps); tmps.forEach((id) => { - preloadChannelMessages({ id, limit: 50 }); + if (id) { + preloadChannelMessages({ id, limit: 50 }); + } }); preloadChannelMsgs = true; } diff --git a/src/routes/chat/SessionList/ContextMenu.tsx b/src/routes/chat/SessionList/ContextMenu.tsx index ee026183..3c249400 100644 --- a/src/routes/chat/SessionList/ContextMenu.tsx +++ b/src/routes/chat/SessionList/ContextMenu.tsx @@ -47,7 +47,7 @@ const SessionContextMenu: FC = ({ }); const handleChannelSetting = () => { - navigateTo(`/setting/channel/${id}?f=${pathname}`); + navigateTo(`/setting/channel/${id}/overview?f=${pathname}`); }; const handleReadAll = () => { diff --git a/src/routes/chat/SessionList/index.tsx b/src/routes/chat/SessionList/index.tsx index d0240149..4eda75bf 100644 --- a/src/routes/chat/SessionList/index.tsx +++ b/src/routes/chat/SessionList/index.tsx @@ -43,7 +43,7 @@ const SessionList: FC = ({ tempSession }) => { return { id, mid, type: "channel" }; }); const uSessions = DMs.map((id) => { - console.log("adddd", id); + // console.log("adddd", id); const mids = userMessage[id]; if (!mids || mids.length == 0) { return { unreads: 0, id, type: "user" }; @@ -57,9 +57,9 @@ const SessionList: FC = ({ tempSession }) => { const { mid: bMid = 0 } = b; return bMid - aMid; }); - console.log("before qqqq", temps); + // console.log("before qqqq", temps); const newSessions = tempSession ? [tempSession, ...temps] : temps; - console.log("qqqq", newSessions); + // console.log("qqqq", newSessions); setSessions(newSessions); }, [ channelIDs, diff --git a/src/routes/home/index.tsx b/src/routes/home/index.tsx index 1a4802db..14ec846a 100644 --- a/src/routes/home/index.tsx +++ b/src/routes/home/index.tsx @@ -56,7 +56,7 @@ function HomePage() { } // 有点绕 const chatNav = isChatHomePath ? "/chat" : chatPath || "/chat"; - console.log("navvvv", isChatHomePath, chatPath); + // console.log("navvvv", isChatHomePath, chatPath); const userNav = userPath || "/users"; const linkClass = `flex items-center gap-2.5 px-3 py-2 font-semibold text-sm text-gray-600 rounded-lg md:hover:bg-gray-800/10`; return ( diff --git a/src/routes/settingChannel/Overview.tsx b/src/routes/settingChannel/Overview.tsx index 83896721..5b7c3d8c 100644 --- a/src/routes/settingChannel/Overview.tsx +++ b/src/routes/settingChannel/Overview.tsx @@ -85,7 +85,7 @@ export default function Overview({ id = 0 }) { } }, [changeTypeSuccess]); - if (!values || !id) return null; + if (!values || !id || !channel) return null; const { name, description } = values; const readOnly = !loginUser?.is_admin && channel?.owner != loginUser?.uid; const inputClass = `w-full flex flex-col items-start gap-2 relative`;