Skip to content

Commit 1cd9ed8

Browse files
authored
Merge pull request #162 from boostcampwm-2021/dev
NogariHouse Release v1.0.1
2 parents 50ae8dc + 6dd71ac commit 1cd9ed8

21 files changed

Lines changed: 230 additions & 44 deletions

File tree

โ€Žclient/src/components/chat/detail-view/footer/index.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function ChatRoomFooter({
3030
key: `${nowDate.getTime()}_${user.userDocumentId}`,
3131
});
3232
chatSocket?.emit('chat:alertMsg', { participants, chatDocumentId });
33-
chatSocket?.emit('chat:updateCount', participants);
33+
chatSocket?.emit('chat:updateCount', participants, chatDocumentId);
3434
addChattingLog({
3535
userDocumentId: user.userDocumentId, userName: user.userName, profileUrl: user.profileUrl, message, date: makeDateToHourMinute(new Date()),
3636
});

โ€Žclient/src/components/chat/detail-view/index.tsxโ€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import roomDocumentIdState from '@atoms/room-document-id';
1515
import roomViewState from '@atoms/room-view-type';
1616
import useChatSocket from '@src/utils/chat-socket';
1717
import isOpenRoomState from '@atoms/is-open-room';
18+
import chatSocketMessage from '@constants/socket-message/chat';
1819
import NotFoundChatView from '@src/components/chat/not-found-view';
1920
import LoadingSpinner from '@styles/loading-spinner';
2021
import { chatReducer, initialState } from './reducer';
@@ -99,13 +100,13 @@ function ChatRoomDetailView() {
99100

100101
useEffect(() => {
101102
if (!chatSocket) return;
102-
chatSocket.emit('chat:roomJoin', chatDocumentId);
103-
chatSocket.on('chat:sendMsg', (payload: any) => {
103+
chatSocket.emit(chatSocketMessage.roomJoin, chatDocumentId);
104+
chatSocket.on(chatSocketMessage.sendMsg, (payload: any) => {
104105
dispatch({ type: 'ADD_CHATTING_LOG', payload: { chatLog: payload } });
105106
});
106107
return () => {
107-
chatSocket.off('chat:sendMsg');
108-
chatSocket.emit('chat:leave', chatDocumentId);
108+
chatSocket.off(chatSocketMessage.sendMsg);
109+
chatSocket.emit(chatSocketMessage.leave, chatDocumentId);
109110
};
110111
}, [chatSocket]);
111112

โ€Žclient/src/components/chat/main-view/style.tsโ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { whiteScroll } from '@styles/scrollbar-style';
44
const ChatUserCardWrap = styled.div`
55
height: calc(100% - 80px);
66
width: 100%;
7+
8+
overflow-x: hidden;
79
${whiteScroll};
810
`;
911

โ€Žclient/src/components/chat/new-view/header/chat-new-header.tsxโ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useHistory } from 'react-router-dom';
44
import useChatSocket from '@utils/chat-socket';
55
import { postChatRoom } from '@api/chat';
66
import userState from '@atoms/user';
7+
import chatSocketMessage from '@constants/socket-message/chat';
78
import { SelectHeaderWrap, SelectHeader, BtnStyle } from '@src/assets/styles/select-view-style';
89

910
const DoneBtn = ({ selectedUserList }: any) => {
@@ -20,7 +21,7 @@ const DoneBtn = ({ selectedUserList }: any) => {
2021
state: { participantsInfo: selectedUserList },
2122
});
2223
if (res.isNew) {
23-
chatSocket.emit('chat:makeChat', {
24+
chatSocket.emit(chatSocketMessage.makeChat, {
2425
chatDocumentId: res.chatDocumentId,
2526
participantsInfo: [...selectedUserList, { userDocumentId: user.userDocumentId, userName: user.userName, profileUrl: user.profileUrl }],
2627
});

โ€Žclient/src/components/common/default-header/index.tsxโ€Ž

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { nowCountState, nowFetchingState, nowItemsListState } from '@atoms/main-
1616
import isOpenSliderMenuState from '@atoms/is-open-slider-menu';
1717
import isOpenRoomState from '@atoms/is-open-room';
1818
import SliderMenu from '@common/menu-modal';
19+
import chatSocketMessage from '@constants/socket-message/chat';
20+
import userSocketMessage from '@constants/socket-message/user';
1921
import { IconAndLink } from '@interfaces/index';
2022
import { getUnReadMsgCount } from '@api/chat';
2123
import getIsActivityChecked from '@api/activity';
@@ -59,20 +61,20 @@ function DefaultHeader() {
5961

6062
useEffect(() => {
6163
getUnReadMsgCount().then((res: any) => setUnReadMsgCount(res.unReadMsgCount));
62-
chatSocket.emit('chat:viewJoin', user.userDocumentId);
63-
chatSocket.on('chat:updateCount', () => {
64-
if (!window.location.pathname.includes('/chat-rooms/')) setUnReadMsgCount((oldCount) => oldCount + 1);
64+
chatSocket.emit(chatSocketMessage.viewJoin, user.userDocumentId);
65+
chatSocket.on(chatSocketMessage.updateCount, (chatDocumentId) => {
66+
if (!window.location.pathname.includes(`${chatDocumentId}`)) setUnReadMsgCount((oldCount) => oldCount + 1);
6567
});
6668
return () => {
67-
chatSocket.off('chat:updateCount');
69+
chatSocket.off(chatSocketMessage.updateCount);
6870
};
6971
}, [chatSocket]);
7072

7173
useEffect(() => {
7274
if (!userSocket) return;
73-
userSocket.on('user:getActivity', () => setActivityChecked(true));
75+
userSocket.on(userSocketMessage.getActivity, () => setActivityChecked(true));
7476
return () => {
75-
userSocket.off('user:getActivity');
77+
userSocket.off(userSocketMessage.getActivity);
7678
};
7779
}, [userSocket]);
7880

โ€Žclient/src/components/common/room-card/index.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function RoomCard({
7575
</RoomCardProfileDiv>
7676
<RoomCardUsers>
7777
{userNameList(userNames)}
78-
<ParticipantsNumberSpan>{`${participantsInfo.length} people`}</ParticipantsNumberSpan>
78+
<ParticipantsNumberSpan>{`${participantsInfo.length} / 6 people`}</ParticipantsNumberSpan>
7979
</RoomCardUsers>
8080
</RoomCardInfo>
8181
</RoomCardLayout>

โ€Žclient/src/components/main/left-sidebar/index.tsxโ€Ž

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useRecoilValue, useSetRecoilState } from 'recoil';
66
import followingListState from '@atoms/following-list';
77
import userState from '@atoms/user';
88
import { IToast } from '@atoms/toast-list';
9+
import userSocketMessage from '@constants/socket-message/user';
910
import toastListSelector from '@selectors/toast-list';
1011
import useUserSocket from '@utils/user-socket';
1112
import ActiveFollowingCard from './active-following-card';
@@ -44,17 +45,17 @@ function LeftSideBar() {
4445
if (!user.isLoggedIn) return;
4546
const userSocket = useUserSocket();
4647

47-
userSocket.on('user:firstFollowingList', (firstActiveFollowingList) => {
48+
userSocket.on(userSocketMessage.firstFollowingList, (firstActiveFollowingList) => {
4849
setFirstFollowingList(firstActiveFollowingList);
4950
});
50-
userSocket.on('user:newActiveUser', (newActiveUserData) => {
51+
userSocket.on(userSocketMessage.newActiveUser, (newActiveUserData) => {
5152
const newDocumentId = newActiveUserData.userDocumentId;
5253
if (followingList.includes(newDocumentId)) addNewActiveFollowing(newActiveUserData);
5354
});
54-
userSocket.on('user:newLeaveUser', (leaveUserDocumentId) => {
55+
userSocket.on(userSocketMessage.newLeaveUser, (leaveUserDocumentId) => {
5556
deleteLeaveActiveFollowing(leaveUserDocumentId);
5657
});
57-
userSocket.on('user:hands', (handsData: { from: Partial<IActiveFollowingUser>, to: string }) => {
58+
userSocket.on(userSocketMessage.hands, (handsData: { from: Partial<IActiveFollowingUser>, to: string }) => {
5859
if (handsData.to === user.userDocumentId) {
5960
const newToast: IToast = {
6061
type: 'info',
@@ -76,15 +77,15 @@ function LeftSideBar() {
7677
useEffect(() => {
7778
const userSocket = useUserSocket();
7879
if (userSocket) {
79-
userSocket.emit('user:join', {
80+
userSocket.emit(userSocketMessage.join, {
8081
...user, followingList,
8182
});
8283
}
8384
}, [followingList]);
8485

8586
const onClickHands = (userDocumentId: string) => (e: MouseEvent) => {
8687
e.stopPropagation();
87-
useUserSocket().emit('user:hands', userDocumentId);
88+
useUserSocket().emit(userSocketMessage.hands, userDocumentId);
8889
};
8990

9091
return (

โ€Žclient/src/components/main/style.tsโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const MainSectionLayout = styled.div`
4040
}
4141
4242
@media (max-width: 768px){
43-
heigth: calc(100% - 100px);
43+
height: calc(100%-100px);
4444
}
4545
4646
@media (min-width: 1025px) {

โ€Žclient/src/components/profile/modal/change-profile-image/index.tsxโ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isOpenChangeProfileImageModalState } from '@atoms/is-open-modal';
88
import { ModalBox, BackgroundWrapper } from '@styles/modal';
99
import userState from '@atoms/user';
1010
import DefaultButton from '@common/default-button';
11+
import userSocketMessage from '@constants/socket-message/user';
1112
import { changeProfileImage } from '@api/user';
1213
import useUserSocket from '@utils/user-socket';
1314
import {
@@ -49,7 +50,7 @@ function ShareModal() {
4950
});
5051
const userSocket = useUserSocket();
5152
if (userSocket) {
52-
userSocket.emit('user:join', {
53+
userSocket.emit(userSocketMessage.join, {
5354
...user, profileUrl: newProfileUrl, followingList,
5455
});
5556
}

โ€Žclient/src/components/room/in-view/index.tsxโ€Ž

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import React, { useEffect, useState, RefObject } from 'react';
22
import { useSetRecoilState, useResetRecoilState } from 'recoil';
33
import { FiPlus, FiMic, FiMicOff } from 'react-icons/fi';
44

5+
import toastListSelector from '@selectors/toast-list';
56
import roomDocumentIdState from '@atoms/room-document-id';
67
import roomViewState from '@atoms/room-view-type';
78
import isOpenRoomState from '@atoms/is-open-room';
89
import { isOpenRoomModalState } from '@atoms/is-open-modal';
910
import DefaultButton from '@common/default-button';
1011
import { IParticipant, InRoomUserBox, InRoomOtherUserBox } from '@components/room/in-view/in-room-user-box';
12+
import roomSocketMessage from '@constants/socket-message/room';
1113
import { getRoomInfo } from '@api/room';
1214
import { useRtc, IRTC } from '@hooks/useRtc';
1315
import {
@@ -27,6 +29,7 @@ function InRoomModal() {
2729
const resetRoomDocumentId = useResetRecoilState(roomDocumentIdState);
2830
const setIsOpenRoom = useSetRecoilState(isOpenRoomState);
2931
const setIsOpenModal = useSetRecoilState(isOpenRoomModalState);
32+
const setToastList = useSetRecoilState(toastListSelector);
3033
const [roomInfo, setRoomInfo] = useState<IRooms>();
3134
const [isMic, setMic] = useState(false);
3235
const [
@@ -37,7 +40,14 @@ function InRoomModal() {
3740
getRoomInfo(roomDocumentId)
3841
.then((res: any) => {
3942
if (!res) setRoomView('notFoundRoomView');
40-
else setRoomInfo(res);
43+
else if (res.participants.length > 5) {
44+
setRoomView('createRoomView');
45+
setToastList({
46+
type: 'danger',
47+
title: '๋ฐฉ ์ ‘์† ์‹คํŒจ',
48+
description: '์ž…์žฅ ๊ฐ€๋Šฅ ์ธ์›์ˆ˜๊ฐ€ ์ดˆ๊ณผ๋˜์–ด ์ž…์žฅ์ด ๋ถˆ๊ฐ€๋Šฅ ํ•ฉ๋‹ˆ๋‹ค',
49+
});
50+
} else setRoomInfo(res);
4151
});
4252

4353
return () => {
@@ -48,7 +58,7 @@ function InRoomModal() {
4858
useEffect(() => {
4959
let isMount = true;
5060

51-
socket?.on('room:mic', ({ userData }: any) => {
61+
socket?.on(roomSocketMessage.mic, ({ userData }: any) => {
5262
if (isMount) {
5363
const newParticipants = participants.reduce((acc: Array<IRTC>, cur: IRTC) => {
5464
if (userData.userDocumentId === cur.userDocumentId) {
@@ -69,12 +79,12 @@ function InRoomModal() {
6979

7080
return () => {
7181
isMount = false;
72-
socket?.off('room:mic');
82+
socket?.off(roomSocketMessage.mic);
7383
};
7484
}, [socket, participants]);
7585

7686
const micToggle = (isMicOn : boolean) => {
77-
socket?.emit('room:mic', { roomDocumentId, userDocumentId: user.userDocumentId, isMicOn });
87+
socket?.emit(roomSocketMessage.mic, { roomDocumentId, userDocumentId: user.userDocumentId, isMicOn });
7888
setMic(isMicOn);
7989
myStreamRef.current!
8090
.getAudioTracks()

0 commit comments

Comments
ย (0)