refactor: updates

This commit is contained in:
zerosoul
2022-03-11 10:30:25 +08:00
parent 501688c960
commit 5d363b5a5f
6 changed files with 108 additions and 107 deletions
+12 -15
View File
@@ -24,7 +24,6 @@ function Message({
content_type = "text/plain",
unread = false,
pending,
removed = false,
edited = false,
likes = {},
}) {
@@ -49,29 +48,27 @@ function Message({
const toggleEmojiPopover = () => {
setEmojiPopVisible((prev) => !prev);
};
useEffect(() => {
if (!unread) {
avatarRef.current?.scrollIntoView();
}
}, [unread]);
// useEffect(() => {
// if (!unread) {
// avatarRef.current?.scrollIntoView();
// }
// }, [unread]);
useEffect(() => {
if (inView) {
if (unread) {
const setMsgRead = gid ? setChannelMsgRead : setUserMsgRead;
disptach(setMsgRead({ id: gid || uid, mid }));
}
if (inView && unread) {
const setMsgRead = gid ? setChannelMsgRead : setUserMsgRead;
disptach(setMsgRead({ id: gid || uid, mid }));
}
}, [gid, mid, uid, unread, inView]);
if (!contacts) return null;
const currUser = contacts.find((c) => c.uid == fromUid) || {};
return removed ? (
"removed"
) : (
return (
<StyledWrapper
ref={myRef}
className={`${menuVisible ? "menu" : ""} ${inView ? "in_view" : ""}`}
className={`message ${menuVisible ? "menu" : ""} ${
inView ? "in_view" : ""
}`}
>
<Tippy
interactive