From fd6167c3034d73a17a044dca20650823397e5fa9 Mon Sep 17 00:00:00 2001 From: Hajung Song Date: Fri, 3 Nov 2023 14:27:24 +0900 Subject: [PATCH] =?UTF-8?q?unread=20=EC=BD=94=EB=93=9C=20=EB=B3=B5?= =?UTF-8?q?=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chat/src/chat/chat.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/chat/src/chat/chat.tsx b/packages/chat/src/chat/chat.tsx index c59be4b068..3d5ffaa687 100644 --- a/packages/chat/src/chat/chat.tsx +++ b/packages/chat/src/chat/chat.tsx @@ -7,6 +7,7 @@ import { closeKeyboard } from '@titicaca/triple-web-to-native-interfaces' import { Container } from '@titicaca/core-elements' import { + HasUnreadOfRoomInterface, ImagePayload, MessageInterface, PostMessageType, @@ -48,7 +49,7 @@ export interface ChatProps { getUnreadRoom?: (option: { roomId: string lastSeenMessageId: number - }) => void + }) => Promise room: RoomInterface notifyNewMessage?: (lastMessage: MessageInterface) => void showFailToast?: (message: string) => void @@ -112,10 +113,22 @@ export const Chat = ({ return } - await getUnreadRoom?.({ + const unreadRoomResult = await getUnreadRoom?.({ roomId: room.id, lastSeenMessageId: lastMessageId, }) + const { hasUnread = false, others = [] } = unreadRoomResult || {} + + const otherUnreadInfo = others.map(({ memberId, lastSeenMessageId }) => ({ + memberId, + lastSeenMessageId: Number(lastSeenMessageId), + })) + dispatch({ + action: ChatActions.UPDATE, + otherUnreadInfo, + }) + + return hasUnread }, [lastMessageId, getUnreadRoom, room.id]) useChatMessage({