Skip to content

Commit

Permalink
[chore] 채팅 입장 더블클릭에서 클릭으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Im-younique committed Dec 11, 2023
1 parent 2e218a7 commit 9a2b6d5
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions client/src/components/Chat/user-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,27 @@ const UserTile = ({
unReadMessageCount,
}: IUserTile) => {
const { openModal } = useModal();
const handleRoomCheck = async () => {

const handleClick = async () => {
if (type === 'room') {
handleEnterRoom({ roomId: roomId as string, roomName: name });
} else {
const otherIds = [userId];
try {
const data = await createChatRoom({
otherIds,
roomName: '',
});
const { roomId, roomName } = data;
handleEnterRoom({ roomId, roomName });
} catch {
openModal({
type: ModalType.ERROR,
message: errorMessage.failedCreateChatRoom,
});
}
}
};

const handleRecommandChatStart = async () => {
const otherIds = [userId];
try {
const data = await createChatRoom({
otherIds,
roomName: name,
});
const { roomId, roomName } = data;
handleEnterRoom({ roomId, roomName });
} catch {
openModal({
type: ModalType.ERROR,
message: errorMessage.failedCreateChatRoom,
});
}
};

Expand All @@ -75,7 +78,7 @@ const UserTile = ({
return (
<div
className={`flex gap-2 font-semibold items-center px-2 py-4 ${addedStyle}`}
onDoubleClick={handleRoomCheck}
onClick={handleClick}
>
<Avatar src={src ? `${BASE_URL}${src}` : ''} alt="user_icon" size="sm" />
<div className="flex flex-col flex-1 overflow-hidden text-left">
Expand All @@ -86,7 +89,10 @@ const UserTile = ({
</div>
<div className="inline-block w-14 h-10 disabled:opacity-70">
{type === 'recommand' ? (
<button className="w-8 text-right sm:w-14" onClick={handleRoomCheck}>
<button
className="w-8 text-right sm:w-14"
onClick={handleRecommandChatStart}
>
<Icon icon="lucide:message-circle" fontSize={28} color="black" />
</button>
) : (
Expand Down

0 comments on commit 9a2b6d5

Please sign in to comment.