Skip to content

Commit

Permalink
unread 코드 복원
Browse files Browse the repository at this point in the history
  • Loading branch information
dongoc committed Nov 3, 2023
1 parent 9420b8c commit fd6167c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/chat/src/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { closeKeyboard } from '@titicaca/triple-web-to-native-interfaces'
import { Container } from '@titicaca/core-elements'

import {
HasUnreadOfRoomInterface,
ImagePayload,
MessageInterface,
PostMessageType,
Expand Down Expand Up @@ -48,7 +49,7 @@ export interface ChatProps {
getUnreadRoom?: (option: {
roomId: string
lastSeenMessageId: number
}) => void
}) => Promise<HasUnreadOfRoomInterface>
room: RoomInterface
notifyNewMessage?: (lastMessage: MessageInterface) => void
showFailToast?: (message: string) => void
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit fd6167c

Please sign in to comment.