Skip to content

Commit

Permalink
Merge pull request #283 from SWM-FIRE/dev
Browse files Browse the repository at this point in the history
release v1.1.0
  • Loading branch information
haryung-lee authored Oct 28, 2022
2 parents e1e0c80 + 8f1e985 commit 9da7e93
Show file tree
Hide file tree
Showing 67 changed files with 1,466 additions and 175 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"react-hot-toast": "^2.3.0",
"react-items-carousel": "^2.8.0",
"react-notion": "^0.10.0",
"react-player": "^2.11.0",
"react-query": "^3.39.1",
"react-router-dom": "6",
"react-scripts": "5.0.1",
Expand Down
13 changes: 13 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="ko">
<head>
<meta charset="UTF-8" />

<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
Expand Down Expand Up @@ -2134,6 +2135,18 @@
/> -->

<title>modoco</title>
<meta property="og:title" content="modoco" />
<meta property="og:type" content="website" />
<meta
property="og:image"
content="https://user-images.githubusercontent.com/64428916/197377529-6b2aa0f2-4e62-4fe6-ad14-137304780733.png"
/>
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:url" content="https://modocode.com/" />
<meta property="og:description" content="모여서 도란도란 같이 코딩해요💻" />
<meta property="og:site_name" content="모도코" />
<meta property="og:locale" content="ko" />
</head>
<body>
<div id="root"></div>
Expand Down
10 changes: 5 additions & 5 deletions src/adapters/receiveMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ const onChatMessage = (roomId: string) => {

useEffect(() => {
const receiveMessage = (receiveMsg) => {
const isMe = receiveMsg.sender === uid;
const isMe = receiveMsg.from === uid;
const userInfo = isMe
? {
uid: receiveMsg.sender,
uid: receiveMsg.from,
nickname,
avatar,
}
: connectedUsers.filter((user) => user.uid === receiveMsg.sender)[0];
: connectedUsers.filter((user) => user.uid === receiveMsg.from)[0];

setMessages([
...messages.map((m, index) => {
if (
index === messages.length - 1 &&
m.uid === receiveMsg.sender &&
m.uid === receiveMsg.from &&
moment(m.createdAt).format('LT') ===
moment(receiveMsg.createdAt).format('LT')
) {
Expand Down Expand Up @@ -74,7 +74,7 @@ const onChatMessage = (roomId: string) => {
moment(receiveMsg.createdAt).format('LT')
) {
isHideNicknameAndAvatar = false;
} else if (msg[msg.length - 1].uid !== receiveMsg.sender) {
} else if (msg[msg.length - 1].uid !== receiveMsg.from) {
isHideNicknameAndAvatar = false;
} else if (msg[msg.length - 1].type !== 'MESSAGE') {
isHideNicknameAndAvatar = false;
Expand Down
4 changes: 4 additions & 0 deletions src/adapters/roomConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export const roomConnection = (roomId: string) => {

joinSuccess();

newSocket?.on('exception', (event) => {
console.log('except', event);
});

newSocket?.on(SOCKET_EVENT.JOINED_ROOM, (room) => {
console.log('[roomConnection] joinedRoom', room);
emitAudioStateChange(roomId, userMic);
Expand Down
99 changes: 99 additions & 0 deletions src/adapters/youtubeSocket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { io } from 'socket.io-client';
import { API } from '../config';
import youtubeSearch from '../interface/youtubeSearch.interface';

const youtubeSocket = {
socket: io(`${API.YOUTUBE_PLAYLIST as string}`, {
transports: ['websocket', 'polling'],
query: { token: localStorage.getItem('access_token') },
}),
};

const generateYoutubeSocket = () => {
youtubeSocket.socket = io(`${API.YOUTUBE_PLAYLIST as string}`, {
transports: ['websocket', 'polling'],
query: { token: localStorage.getItem('access_token') },
});
};

const initSocketConnection = () => {
if (!youtubeSocket.socket) generateYoutubeSocket();
youtubeSocket.socket?.connect();
};

const checkSocket = () => {
if (!youtubeSocket.socket || !youtubeSocket.socket.connected) {
initSocketConnection();
}
};

const disconnectSocket = () => {
youtubeSocket.socket?.off('connect');
youtubeSocket.socket?.off('playlist:join');
youtubeSocket.socket?.off('playlist:joined');
youtubeSocket.socket?.off('playlist:sync');
youtubeSocket.socket?.disconnect();
};

const connectedYoutube = () => {
youtubeSocket.socket?.on('connect', () => {
console.log(`[youtube connect] connected! ${youtubeSocket.socket?.id}`);
});
};

const joinYoutube = (roomId: string) => {
checkSocket();
youtubeSocket.socket?.emit('playlist:join', {
room: roomId,
playlistName: 'playlistItem',
});
console.log(
`[emit join] waiting for join ${roomId}! ${youtubeSocket.socket?.id}`,
);
};

// const joinedYoutube = () => {
// youtubeSocket.socket?.on('playlist:joined', (roomId: string) => {
// console.log(`[on join] joined ${roomId}! ${youtubeSocket.socket?.id}`);
// });
// };

const selectVideo = (roomId: string, video: youtubeSearch) => {
checkSocket();
youtubeSocket.socket?.emit('playlist:sync', {
room: roomId,
playlistName: 'playlistItem',
type: 'sync',
playlist: [{ video }],
});
console.log(
`[emit select] select ${video.id.videoId}! ${youtubeSocket.socket?.id}`,
);
};

const addVideo = (addFunc) => {
checkSocket();
youtubeSocket.socket?.on('playlist:sync', (data) => addFunc(data));
console.log(`[on add] add video! ${youtubeSocket.socket?.id}`);
};

const leaveYoutube = (roomId: string) => {
checkSocket();
youtubeSocket.socket?.emit('playlist:leave', {
room: roomId,
playlistName: 'playlistItem',
});
console.log(`[emit leave] leave ${roomId}! ${youtubeSocket.socket?.id}`);
};

export {
youtubeSocket,
initSocketConnection,
// generateYoutubeSocket,
disconnectSocket,
connectedYoutube,
joinYoutube,
selectVideo,
addVideo,
leaveYoutube,
};
1 change: 1 addition & 0 deletions src/api/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { awsRequest } from './awsLambdaAxios';
export { authorizationRequest, unAuthorizationRequest } from './backendAxios';
export { youtubeAxios } from './youtubeAxios';
28 changes: 28 additions & 0 deletions src/api/core/youtubeAxios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import axios from 'axios';
import { API } from '../../config';

const youtubeAxios = axios.create({
baseURL: API.YOUTUBE,
});

// add youtube key in params
youtubeAxios.interceptors.request.use((config) => {
return Object.assign(config, {
params: {
...config.params,
key: process.env.REACT_APP_YOUTUBE_KEY,
},
});
});

youtubeAxios.interceptors.response.use(
(response) => {
return response;
},
(error) => {
console.warn('[Axios] ', error);
return Promise.reject(error);
},
);

export { youtubeAxios };
26 changes: 26 additions & 0 deletions src/api/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
authorizationRequest,
unAuthorizationRequest,
awsRequest,
youtubeAxios,
} from './core/index';
import { API } from '../config';

Expand Down Expand Up @@ -139,6 +140,29 @@ const getRecords = () => {
return authorizationRequest.get(API.RECORDS);
};

/**
* youtube
*/

// search youtube video
const searchYoutubeVideo = (keyword: string) => {
return youtubeAxios.get(API.YOUTUBE_SEARCH, {
params: {
q: keyword,
part: 'snippet',
maxResults: 15,
type: 'video',
videoEmbeddable: true,
videoCategoryId: 10,
},
});
};

// delete room
const deleteRoom = (roomId: number) => {
return authorizationRequest.delete((API.ROOM as string) + roomId);
};

export {
getUser,
getMe,
Expand All @@ -156,4 +180,6 @@ export {
getFriend,
getRecords,
changeProfile,
searchYoutubeVideo,
deleteRoom,
};
2 changes: 2 additions & 0 deletions src/assets/svg/Check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/svg/GrayYoutube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/assets/svg/MusicOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/assets/svg/MusicOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/assets/svg/RedYoutube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/assets/svg/Search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/assets/svg/WhiteYoutube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/assets/svg/verticalMenu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/components/atoms/chatting/SendChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function SendChat({
newSocket.emit('chatMessage', {
room: roomId,
type: 'MESSAGE',
sender: uid,
from: uid,
message: newMessage,
createdAt: new Date(),
});
Expand Down Expand Up @@ -93,6 +93,8 @@ const Input = styled.textarea<{ roomId: string }>`
color: rgba(255, 255, 255, 1);
min-height: 2rem;
max-height: 13rem;
resize: none;
::-webkit-scrollbar {
width: 0.3rem;
}
Expand Down
Loading

0 comments on commit 9da7e93

Please sign in to comment.