Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/MOVIEJOJO7/cat-talk into Fe…
Browse files Browse the repository at this point in the history
…ature/#111
  • Loading branch information
TaePoong719 committed Nov 16, 2023
2 parents 815882f + af6adb1 commit ae93685
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Components/Chat/ChatRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ChatHeader from '@/Components/Chat/ChatHeader';
import RenderChats from '@/Components/Chat/RenderChats';
import Image from 'next/image';
import Swal from 'sweetalert2';
import { getCookie } from '../Login/Cookie';

const ChatRoom = ({
socket,
Expand All @@ -24,6 +25,7 @@ const ChatRoom = ({
const [newMessage, setNewMessage] = useState('');
const [chatUsers, setChatUsers] = useState<User[]>([]);
const [chatName, setChatName] = useState('');
const userId = getCookie('userId');

// 채팅 참여 유저 블러오기
useEffect(() => {
Expand Down Expand Up @@ -85,7 +87,10 @@ const ChatRoom = ({
if (socket?.connected) {
socket.on('join', (responseData) => {
setChatUsers([...chatUsers, ...responseData.users]);
Swal.fire(`${responseData.users[0]} 님이 입장하셨습니다.`);

if (responseData.users[0] !== userId) {
Swal.fire(`${responseData.leaver} 님이 퇴장하셨습니다.`);
}
});
}

Expand All @@ -100,7 +105,10 @@ const ChatRoom = ({
if (socket?.connected) {
socket.on('leave', (responseData) => {
setChatUsers([...chatUsers, ...responseData.users]);
Swal.fire(`${responseData.leaver} 님이 퇴장하셨습니다.`);

if (responseData.leaver !== userId) {
Swal.fire(`${responseData.leaver} 님이 퇴장하셨습니다.`);
}
});
}

Expand Down
6 changes: 4 additions & 2 deletions Components/Search/OpenChatModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ const OpenChatModal = ({ modalChat }: { modalChat: Chat }) => {
<Image
src={modalChat.users[0]?.picture}
alt="user picture"
fill={true}
layout={'fill'}
objectFit={'cover'}
quality={100}
priority={true}
style={{ opacity: 0.5 }}
/>

<button
type="button"
className="absolute left-5 top-5 text-white text-lg"
Expand All @@ -58,7 +60,7 @@ const OpenChatModal = ({ modalChat }: { modalChat: Chat }) => {
</div>
<button
type="button"
className="w-full h-24 rounded-none bg-text text-2xl text-white opacity-100 hover:bg-opacity-75 transition duration-500 ease-linear font-thin absolute bottom-0"
className="w-full h-20 rounded-none bg-text text-2xl text-white opacity-100 hover:bg-opacity-75 transition duration-500 ease-linear font-thin absolute bottom-0"
onClick={joinChat}
>
오픈 채팅방 참여하기
Expand Down

0 comments on commit ae93685

Please sign in to comment.