chore: tweaks

This commit is contained in:
Tristan Yang
2023-03-13 18:32:06 +08:00
parent ebfc362705
commit 0bf167e4e8
7 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ const LinkifyText = ({ url = true, mention = true, mentionTextOnly = false, ment
</a>; </a>;
}, },
url: ({ content, attributes: { href: link } }) => { url: ({ content, attributes: { href: link } }) => {
console.log("attr", link); // console.log("attr", link);
if (!url) return <>{content}</>; if (!url) return <>{content}</>;
return <> return <>
<a className="link" target="_blank" href={link} rel="noreferrer"> <a className="link" target="_blank" href={link} rel="noreferrer">
+2 -1
View File
@@ -63,7 +63,7 @@ const Message: FC<IProps> = ({
} }
} }
}, [mid, read]); }, [mid, read]);
if (!message) return null;
const { const {
reply_mid, reply_mid,
from_uid: fromUid, from_uid: fromUid,
@@ -91,6 +91,7 @@ const Message: FC<IProps> = ({
const _key = properties?.local_id || mid; const _key = properties?.local_id || mid;
const showExpire = (expires_in ?? 0) > 0; const showExpire = (expires_in ?? 0) > 0;
return ( return (
<div <div
key={_key} key={_key}
onContextMenu={readOnly ? undefined : handleContextMenuEvent} onContextMenu={readOnly ? undefined : handleContextMenuEvent}
+4 -1
View File
@@ -60,8 +60,11 @@ export default function usePreload() {
useEffect(() => { useEffect(() => {
if (isGuest && channelIds.length > 0 && !preloadChannelMsgs) { if (isGuest && channelIds.length > 0 && !preloadChannelMsgs) {
const tmps = channelIds.filter((cid) => !channelMessageData[cid]); const tmps = channelIds.filter((cid) => !channelMessageData[cid]);
// console.log("preload", channelIds, tmps);
tmps.forEach((id) => { tmps.forEach((id) => {
preloadChannelMessages({ id, limit: 50 }); if (id) {
preloadChannelMessages({ id, limit: 50 });
}
}); });
preloadChannelMsgs = true; preloadChannelMsgs = true;
} }
+1 -1
View File
@@ -47,7 +47,7 @@ const SessionContextMenu: FC<Props> = ({
}); });
const handleChannelSetting = () => { const handleChannelSetting = () => {
navigateTo(`/setting/channel/${id}?f=${pathname}`); navigateTo(`/setting/channel/${id}/overview?f=${pathname}`);
}; };
const handleReadAll = () => { const handleReadAll = () => {
+3 -3
View File
@@ -43,7 +43,7 @@ const SessionList: FC<Props> = ({ tempSession }) => {
return { id, mid, type: "channel" }; return { id, mid, type: "channel" };
}); });
const uSessions = DMs.map((id) => { const uSessions = DMs.map((id) => {
console.log("adddd", id); // console.log("adddd", id);
const mids = userMessage[id]; const mids = userMessage[id];
if (!mids || mids.length == 0) { if (!mids || mids.length == 0) {
return { unreads: 0, id, type: "user" }; return { unreads: 0, id, type: "user" };
@@ -57,9 +57,9 @@ const SessionList: FC<Props> = ({ tempSession }) => {
const { mid: bMid = 0 } = b; const { mid: bMid = 0 } = b;
return bMid - aMid; return bMid - aMid;
}); });
console.log("before qqqq", temps); // console.log("before qqqq", temps);
const newSessions = tempSession ? [tempSession, ...temps] : temps; const newSessions = tempSession ? [tempSession, ...temps] : temps;
console.log("qqqq", newSessions); // console.log("qqqq", newSessions);
setSessions(newSessions); setSessions(newSessions);
}, [ }, [
channelIDs, channelIDs,
+1 -1
View File
@@ -56,7 +56,7 @@ function HomePage() {
} }
// 有点绕 // 有点绕
const chatNav = isChatHomePath ? "/chat" : chatPath || "/chat"; const chatNav = isChatHomePath ? "/chat" : chatPath || "/chat";
console.log("navvvv", isChatHomePath, chatPath); // console.log("navvvv", isChatHomePath, chatPath);
const userNav = userPath || "/users"; 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`; 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 ( return (
+1 -1
View File
@@ -85,7 +85,7 @@ export default function Overview({ id = 0 }) {
} }
}, [changeTypeSuccess]); }, [changeTypeSuccess]);
if (!values || !id) return null; if (!values || !id || !channel) return null;
const { name, description } = values; const { name, description } = values;
const readOnly = !loginUser?.is_admin && channel?.owner != loginUser?.uid; const readOnly = !loginUser?.is_admin && channel?.owner != loginUser?.uid;
const inputClass = `w-full flex flex-col items-start gap-2 relative`; const inputClass = `w-full flex flex-col items-start gap-2 relative`;