-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#601 add unread num chatting #692
base: dev
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for taxi-dev-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -20,6 +20,7 @@ declare global { | |||
| `${PixelValue} ${PixelValue} ${PixelValue} ${PixelValue}`; | |||
type Padding = Margin; | |||
type User = { | |||
readAt: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type을 any
보다는 구체적으로 명시하는 것이 좋을 것 같습니다 !
readAt: any; | |
readAt?: Date; |
@@ -44,6 +44,17 @@ export default ( | |||
chatBodyRef.current.scrollTop = scrollTop; | |||
}, [chats]); | |||
|
|||
const lastChat = chats.length > 0 ? chats[chats.length - 1] : {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const lastChat = chats.length > 0 ? chats[chats.length - 1] : {}; | |
const lastChat = chats.at(-1); |
로 더 간단히 할 수 있을 것 같아요.
data: { roomId }, | ||
}) | ||
); | ||
}, ["time" in lastChat ? lastChat?.time : ""]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, ["time" in lastChat ? lastChat?.time : ""]); | |
}, [lastChat?.time, roodId]); |
과 차이가 없을 것 같습니다 ! 그리고 roodId
도 추가되어야 할 것 같아요.
const readAts = useMemo(() => { | ||
const readAts = roomInfo?.part?.map((user) => user?.readAt); | ||
return readAts; | ||
}, [chats, roomInfo]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
연산에서 chats
가 사용되지 않아 dependency array 에서 제외되어도 될 것 같아요.
const readAts = useMemo(() => { | |
const readAts = roomInfo?.part?.map((user) => user?.readAt); | |
return readAts; | |
}, [chats, roomInfo]); | |
const readAts = useMemo( | |
() => roomInfo?.part?.map((user) => user?.readAt) || [], | |
[roomInfo] | |
); |
{readAts?.filter((readAt) => readAt < chat.time).length == 0 | ||
? null | ||
: readAts?.filter((readAt) => readAt < chat.time).length} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
같은 연산이 두 번 반복되는데, 한 번의 계산으로 줄일 수 있을 것 같습니다 !
Summary
It closes #601
Images or Screenshots
Further Work