Skip to content

Commit

Permalink
Fix: 채팅 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 committed Oct 8, 2023
1 parent 284138d commit ef2e181
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/RoundCheckIn/CallAdminChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,23 @@ const CallAdminChat = ({
setInputMessage('');
};

const findUserIMG = (playerMatchId: number): string => {
const user = players.find((player) => player.matchPlayerId === playerMatchId);
const findUserIMG = (playerParticipantId: number): string => {
const user = players.find((player) => player.participantId === playerParticipantId);

if (!user) return '';
return user.profileSrc;
};

const findUserName = (playerMatchId: number): string => {
const user = players.find((player) => player.matchPlayerId === playerMatchId);
const findUserName = (playerParticipantId: number): string => {
const user = players.find((player) => player.participantId === playerParticipantId);
if (!user) return '';
return user.gameId;
};

useEffect(() => {
if (!client) return;
const subscription = client.subscribe(`/match/${matchId}/chat`, (data) => {
setChats([...chats, JSON.parse(data.body)]);
setChats((prevChat) => [...prevChat, JSON.parse(data.body)]);
});

return () => {
Expand All @@ -98,14 +99,14 @@ const CallAdminChat = ({
<ChattingContent>
<ImageWrapper>
<Image
src={findUserIMG(message.matchId)}
src={findUserIMG(message.participantId)}
alt='프로필사진'
width={45}
height={45}
/>
</ImageWrapper>
<ContentWrapper>
<ContentName>{findUserName(message.matchId)}</ContentName>
<ContentName>{findUserName(message.participantId)}</ContentName>
<ContentText>{message.content}</ContentText>
</ContentWrapper>
</ChattingContent>
Expand All @@ -120,6 +121,7 @@ const CallAdminChat = ({
<InputChat
type='text'
placeholder='메세지를 입력해주세요'
value={inputMessage}
onChange={handleInputMessage}
onKeyUp={handleKeyPress}
/>
Expand Down

0 comments on commit ef2e181

Please sign in to comment.