From e2c21b9a3e80b0561a9f0d064423b8fb6c0d00a6 Mon Sep 17 00:00:00 2001 From: Hajung Song Date: Tue, 31 Oct 2023 11:17:43 +0900 Subject: [PATCH 1/6] =?UTF-8?q?message=EC=97=90=20sender=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chat/src/chat-bubble/chat-bubble.tsx | 20 ++++++------------- packages/chat/src/chat/chat.tsx | 5 +++-- packages/chat/src/types/index.ts | 1 + 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/chat/src/chat-bubble/chat-bubble.tsx b/packages/chat/src/chat-bubble/chat-bubble.tsx index 2f680c5887..7f9e5cc14d 100644 --- a/packages/chat/src/chat-bubble/chat-bubble.tsx +++ b/packages/chat/src/chat-bubble/chat-bubble.tsx @@ -7,7 +7,6 @@ import { OtherUnreadInterface, PostMessageActionType, TextPayload, - UserInfoInterface, UserType, } from '../types' import { getProfileImageUrl } from '../utils' @@ -16,7 +15,7 @@ import { ChatBubbleStyle } from '../types/ui' import { ChatBubbleUI } from './chat-bubble-ui' interface ChatBubbleProps { - userInfo: UserInfoInterface + my: boolean message: MessageInterface otherReadInfo?: OtherUnreadInterface[] displayTarget: UserType @@ -29,9 +28,9 @@ interface ChatBubbleProps { } const ChatBubble = ({ + my, message, - message: { senderId, createdAt }, - userInfo: { me, others }, + message: { sender, createdAt }, otherReadInfo, displayTarget: componentDisplayTarget, postMessageAction, @@ -41,11 +40,6 @@ const ChatBubble = ({ blindedText, bubbleStyle, }: ChatBubbleProps) => { - const otherUserInfo = useMemo( - () => others.find((other) => other.id === senderId), - [senderId, others], - ) - const unreadCount = !disableUnreadCount && otherReadInfo ? otherReadInfo.reduce( @@ -92,11 +86,9 @@ const ChatBubble = ({ return ( (
  • (
  • Date: Tue, 31 Oct 2023 11:21:16 +0900 Subject: [PATCH 2/6] =?UTF-8?q?userInfo=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=20me=20=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chat/src/chat/chat.tsx | 101 +++++++++++++++----------------- 1 file changed, 46 insertions(+), 55 deletions(-) diff --git a/packages/chat/src/chat/chat.tsx b/packages/chat/src/chat/chat.tsx index dac3b3ca7a..3d5ffaa687 100644 --- a/packages/chat/src/chat/chat.tsx +++ b/packages/chat/src/chat/chat.tsx @@ -14,7 +14,7 @@ import { RoomInterface, TextPayload, UpdateChatData, - UserInfoInterface, + UserInterface, UserType, } from '../types' import ChatBubble from '../chat-bubble' @@ -30,10 +30,7 @@ export const CHAT_CONTAINER_ID = 'chat-inner-container' export interface ChatProps { displayTarget: UserType - /** - * me(sender), others(receiver)에 대한 기본 정보 - */ - userInfo: UserInfoInterface + me: UserInterface /** * 초기 메시지들 */ @@ -72,7 +69,7 @@ export interface ChatProps { */ export const Chat = ({ displayTarget, - userInfo, + me, room, messages: initMessages, beforeSentMessages: initBeforeSentMessages, @@ -136,7 +133,7 @@ export const Chat = ({ useChatMessage({ roomId: room.id, - userMeId: userInfo.me.id, + userMeId: me.id, notifyNewMessage, dispatch, updateChatData, @@ -232,10 +229,10 @@ export const Chat = ({ message: { id: new Date().getTime(), roomId: room.id, - senderId: userInfo.me.id, + senderId: me.id, payload, displayTarget: 'all', - sender: userInfo.me, + sender: me, }, }) @@ -305,52 +302,46 @@ export const Chat = ({ - {userInfo ? ( - <> -
      - {[...messages, ...beforeSentMessages].map( - (message: MessageInterface) => ( -
    • - -
    • - ), - )} -
    -
      - {failedMessages.map((message: MessageInterface) => ( -
    • - -
    • - ))} -
    - - ) : null} +
      + {[...messages, ...beforeSentMessages].map( + (message: MessageInterface) => ( +
    • + +
    • + ), + )} +
    +
      + {failedMessages.map((message: MessageInterface) => ( +
    • + +
    • + ))} +
    From b4f7548ca00c3ab42b6cec36d01f920a37235fa9 Mon Sep 17 00:00:00 2001 From: Hajung Song Date: Tue, 31 Oct 2023 11:23:27 +0900 Subject: [PATCH 3/6] =?UTF-8?q?pusher=EC=99=80=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EB=90=98=EB=8A=94=20unread=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chat/src/chat/chat.tsx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/chat/src/chat/chat.tsx b/packages/chat/src/chat/chat.tsx index 3d5ffaa687..02ed966a7f 100644 --- a/packages/chat/src/chat/chat.tsx +++ b/packages/chat/src/chat/chat.tsx @@ -113,22 +113,10 @@ export const Chat = ({ return } - const unreadRoomResult = await getUnreadRoom?.({ + 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({ From 6ca36d18eb49fdb7aaa148ccc967c5b6b095b6a6 Mon Sep 17 00:00:00 2001 From: Hajung Song Date: Tue, 31 Oct 2023 12:27:33 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=EC=98=88=EC=8B=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chat/src/utils/constants.ts | 84 +++++++++++++++++++--------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/packages/chat/src/utils/constants.ts b/packages/chat/src/utils/constants.ts index bb64d516da..0cc0878bc2 100644 --- a/packages/chat/src/utils/constants.ts +++ b/packages/chat/src/utils/constants.ts @@ -37,33 +37,17 @@ export const MEDIA_ARGS: ChatContextValue = { export const CHAT_ARGS: ChatProps = { displayTarget: UserType.TNA_PARTNER, - userInfo: { - me: { - id: '61ea67f0de3e37001997a80f', - type: UserType.TNA_PARTNER, - identifier: '130', - code: 'TNA_BPM', - profile: { - name: 'TNA_BPM', - thumbnail: - 'https://s3.ap-northeast-2.amazonaws.com/triple-tna-dev/partner/logo/1e2496ab-8725-4df4-84c7-db9804d3c71d.jpeg', - message: '', - }, + me: { + id: '61ea67f0de3e37001997a80f', + type: UserType.TNA_PARTNER, + identifier: '130', + code: 'TNA_BPM', + profile: { + name: 'TNA_BPM', + thumbnail: + 'https://s3.ap-northeast-2.amazonaws.com/triple-tna-dev/partner/logo/1e2496ab-8725-4df4-84c7-db9804d3c71d.jpeg', + message: '', }, - others: [ - { - id: '6344be9953749900140bca42', - type: UserType.TRIPLE_USER, - identifier: '4043', - code: '_KA2408084137-1661761357899', - profile: { - name: '후라이', - thumbnail: - 'https://media.triple.guide/triple-dev/c_limit,f_auto,h_2048,w_2048/52557846-363d-430a-9afd-1cd7fd4fe0b4.jpeg', - message: '', - }, - }, - ], }, getMessages: async () => { return [ @@ -96,6 +80,18 @@ export const CHAT_ARGS: ChatProps = { message: '안녕하세요.\nTNA_BPM입니다. 예약해주셔서 감사합니다!\n\n궁금한 점이 있으시면 TNA_BPM 문의를 편하게 이용해주세요.', }, + sender: { + id: '61ea67f0de3e37001997a80f', + type: UserType.TNA_PARTNER, + identifier: '130', + code: 'TNA_BPM', + profile: { + name: 'TNA_BPM', + thumbnail: + 'https://s3.ap-northeast-2.amazonaws.com/triple-tna-dev/partner/logo/1e2496ab-8725-4df4-84c7-db9804d3c71d.jpeg', + message: '', + }, + }, }, { id: 5749, @@ -107,6 +103,18 @@ export const CHAT_ARGS: ChatProps = { type: MessageType.TEXT, message: '테스트 메시지', }, + sender: { + id: '6344be9953749900140bca42', + type: UserType.TRIPLE_USER, + identifier: '4043', + code: '1', + profile: { + name: '후라이', + thumbnail: + 'https://media.triple.guide/triple-dev/c_limit,f_auto,h_2048,w_2048/52557846-363d-430a-9afd-1cd7fd4fe0b4.jpeg', + message: '', + }, + }, }, ] }, @@ -153,6 +161,18 @@ export const CHAT_ARGS: ChatProps = { type: MessageType.TEXT, message: '테스트 메시지', }, + sender: { + id: '6344be9953749900140bca42', + type: UserType.TRIPLE_USER, + identifier: '4043', + code: '1', + profile: { + name: '후라이', + thumbnail: + 'https://media.triple.guide/triple-dev/c_limit,f_auto,h_2048,w_2048/52557846-363d-430a-9afd-1cd7fd4fe0b4.jpeg', + message: '', + }, + }, }, unreadCount: 0, metadata: { @@ -171,6 +191,18 @@ export const CHAT_ARGS: ChatProps = { createdAt: '2022-11-04T06:44:57.017Z', displayTarget: 'all', payload, + sender: { + id: '61ea67f0de3e37001997a80f', + type: UserType.TNA_PARTNER, + identifier: '130', + code: 'TNA_BPM', + profile: { + name: 'TNA_BPM', + thumbnail: + 'https://s3.ap-northeast-2.amazonaws.com/triple-tna-dev/partner/logo/1e2496ab-8725-4df4-84c7-db9804d3c71d.jpeg', + message: '', + }, + }, }, ], } From 517bd9f7ef9e2aba066c4e45d24c39793d82a0e4 Mon Sep 17 00:00:00 2001 From: Hajung Song Date: Wed, 1 Nov 2023 14:29:59 +0900 Subject: [PATCH 5/6] =?UTF-8?q?getUnreadRoom=20prop=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chat/src/chat/chat.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/chat/src/chat/chat.tsx b/packages/chat/src/chat/chat.tsx index 02ed966a7f..c59be4b068 100644 --- a/packages/chat/src/chat/chat.tsx +++ b/packages/chat/src/chat/chat.tsx @@ -7,7 +7,6 @@ import { closeKeyboard } from '@titicaca/triple-web-to-native-interfaces' import { Container } from '@titicaca/core-elements' import { - HasUnreadOfRoomInterface, ImagePayload, MessageInterface, PostMessageType, @@ -49,7 +48,7 @@ export interface ChatProps { getUnreadRoom?: (option: { roomId: string lastSeenMessageId: number - }) => Promise + }) => void room: RoomInterface notifyNewMessage?: (lastMessage: MessageInterface) => void showFailToast?: (message: string) => void From 4baba7b8a1462123f1b9aa23bb928740186dd62a Mon Sep 17 00:00:00 2001 From: Hajung Song Date: Fri, 3 Nov 2023 14:27:24 +0900 Subject: [PATCH 6/6] =?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({