Skip to content
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

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

Conversation

twkim-0501
Copy link
Contributor

@twkim-0501 twkim-0501 commented Nov 8, 2023

Summary

It closes #601

Images or Screenshots

Further Work

  • Do something...

@twkim-0501 twkim-0501 linked an issue Nov 8, 2023 that may be closed by this pull request
Copy link

netlify bot commented Nov 8, 2023

Deploy Preview for taxi-dev-preview ready!

Name Link
🔨 Latest commit 0363049
🔍 Latest deploy log https://app.netlify.com/sites/taxi-dev-preview/deploys/6596076a9ff06200087a0624
😎 Deploy Preview https://deploy-preview-692--taxi-dev-preview.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@twkim-0501 twkim-0501 requested a review from 14KGun November 9, 2023 05:40
@twkim-0501 twkim-0501 self-assigned this Nov 9, 2023
@14KGun 14KGun marked this pull request as draft November 9, 2023 12:11
@14KGun 14KGun changed the title WiP #601 add unread num chatting #601 add unread num chatting Nov 9, 2023
@14KGun 14KGun added the chatting label Nov 9, 2023
@14KGun 14KGun marked this pull request as ready for review January 2, 2024 10:24
@@ -20,6 +20,7 @@ declare global {
| `${PixelValue} ${PixelValue} ${PixelValue} ${PixelValue}`;
type Padding = Margin;
type User = {
readAt: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type을 any 보다는 구체적으로 명시하는 것이 좋을 것 같습니다 !

Suggested change
readAt: any;
readAt?: Date;

@@ -44,6 +44,17 @@ export default (
chatBodyRef.current.scrollTop = scrollTop;
}, [chats]);

const lastChat = chats.length > 0 ? chats[chats.length - 1] : {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const lastChat = chats.length > 0 ? chats[chats.length - 1] : {};
const lastChat = chats.at(-1);

로 더 간단히 할 수 있을 것 같아요.

data: { roomId },
})
);
}, ["time" in lastChat ? lastChat?.time : ""]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, ["time" in lastChat ? lastChat?.time : ""]);
}, [lastChat?.time, roodId]);

과 차이가 없을 것 같습니다 ! 그리고 roodId 도 추가되어야 할 것 같아요.

Comment on lines +62 to +65
const readAts = useMemo(() => {
const readAts = roomInfo?.part?.map((user) => user?.readAt);
return readAts;
}, [chats, roomInfo]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

연산에서 chats가 사용되지 않아 dependency array 에서 제외되어도 될 것 같아요.

Suggested change
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]
);

Comment on lines +185 to +187
{readAts?.filter((readAt) => readAt < chat.time).length == 0
? null
: readAts?.filter((readAt) => readAt < chat.time).length}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

같은 연산이 두 번 반복되는데, 한 번의 계산으로 줄일 수 있을 것 같습니다 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

채팅 메시지에 안읽은 사람 수 추가하기
3 participants