Skip to content

Commit f3479e9

Browse files
committed
2 parents 7b7fb53 + bde83c0 commit f3479e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+839
-338
lines changed

β€Žclient/src/App.tsxβ€Ž

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
33
import { getAuth } from 'src/apis/auth';
44
import UserContext from 'src/contexts/user';
55
import { LoadingPage, LoginPage, OAuthPage, WorkspacePage } from 'src/pages';
6-
import { UserInfo } from 'src/types/user';
6+
import { User } from 'src/types/user';
77

88
import 'styles/reset.scss';
99

1010
function App() {
1111
const [isLoaded, setIsLoaded] = useState<boolean>(false);
12-
const [userInfo, setUserInfo] = useState<UserInfo | null>(null);
12+
const [user, setUser] = useState<User | null>(null);
1313

1414
const navigate = useNavigate();
1515
const location = useLocation();
1616

1717
const autoLogin = async () => {
18-
const { user, workspaces } = await getAuth();
18+
const { user } = await getAuth();
1919

2020
setIsLoaded(true);
2121

@@ -24,22 +24,20 @@ function App() {
2424
return;
2525
}
2626

27-
setUserInfo({ user, workspaces });
28-
29-
const { id } = workspaces[0];
30-
navigate(`/workspace/${id}`);
27+
setUser(user);
28+
navigate('/workspace');
3129
};
3230

3331
useEffect(() => {
3432
autoLogin();
3533
}, []);
3634

3735
return isLoaded ? (
38-
<UserContext.Provider value={{ userInfo, setUserInfo }}>
36+
<UserContext.Provider value={{ user, setUser }}>
3937
<Routes>
4038
<Route path="/" element={<LoginPage />} />
4139
<Route path="/oauth" element={<OAuthPage />} />
42-
<Route path="/workspace/:id" element={<WorkspacePage />} />
40+
<Route path="/workspace/*" element={<WorkspacePage />} />
4341
</Routes>
4442
</UserContext.Provider>
4543
) : (

β€Žclient/src/apis/auth.tsβ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { PostLoginParams } from 'params/auth';
2-
import { GetUserInfo } from 'src/types/workspace';
2+
import { User } from 'src/types/user';
3+
import { Workspace } from 'src/types/workspace';
34

45
import { http } from './http';
56
import { CREATED, OK } from './http-status';
67

8+
// TODO: BE API λ³€κ²½ν•  λ•Œ 제거
9+
type GetUserInfo = {
10+
user: User;
11+
workspaces: Workspace[];
12+
};
13+
714
export const getAuth = async (): Promise<GetUserInfo> => {
815
const res = await http.get(`/auth`);
916

β€Žclient/src/apis/user.tsβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { GetWorkspaceParams } from 'params/user';
1+
import { GetWorkspaceParams, GetWorkspacesResBody } from 'params/user';
22

33
import { http } from './http';
44
import { OK } from './http-status';
55

6-
export const getWorkspaces = async ({ id }: GetWorkspaceParams) => {
6+
export const getWorkspaces = async ({
7+
id,
8+
}: GetWorkspaceParams): Promise<GetWorkspacesResBody> => {
79
const res = await http.get(`/user/${id}/workspace`);
810

911
if (res.status !== OK) throw new Error();

β€Žclient/src/components/ConfMediaBar/StreamButton/CamButton/index.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ function CamButton({ isOn, setIsCamOn }: CamButtonProps) {
1616
return (
1717
<button onClick={onClick}>
1818
{isOn ? (
19-
<MdVideocamOff color={color.red} size={20} />
20-
) : (
2119
<MdVideocam color={color.green} size={20} />
20+
) : (
21+
<MdVideocamOff color={color.red} size={20} />
2222
)}
2323
</button>
2424
);

β€Žclient/src/components/ConfMediaBar/StreamButton/MicButton/index.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ function MicButton({ isOn, setIsMicOn }: MicButtonProps) {
1616
return (
1717
<button onClick={onClick}>
1818
{isOn ? (
19-
<MdMicOff color={color.red} size={20} />
20-
) : (
2119
<MdMic color={color.green} size={20} />
20+
) : (
21+
<MdMicOff color={color.red} size={20} />
2222
)}
2323
</button>
2424
);

β€Žclient/src/components/ConfMediaBar/index.tsxβ€Ž

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import { useConfMediaStreams } from 'src/hooks/useConfMediaStreams';
33
import useSocketContext from 'src/hooks/useSocketContext';
44

@@ -7,18 +7,30 @@ import StreamButton from './StreamButton';
77
import style from './style.module.scss';
88

99
function ConfMediaBar() {
10-
const { signalingSocket: socket } = useSocketContext();
11-
const streams = useConfMediaStreams(socket);
10+
const { workspaceSocket: socket } = useSocketContext();
11+
const [streams, setMyTrack] = useConfMediaStreams(socket);
1212

13-
const [isMicOn, setIsMicOn] = useState(false);
14-
const [isCamOn, setIsCamOn] = useState(false);
13+
const [isMicOn, setIsMicOn] = useState(true);
14+
const [isCamOn, setIsCamOn] = useState(true);
15+
16+
useEffect(() => {
17+
setMyTrack('audio', isMicOn);
18+
}, [isMicOn]);
19+
20+
useEffect(() => {
21+
setMyTrack('video', isCamOn);
22+
}, [isCamOn]);
1523

1624
return (
1725
<div className={style['conf-bar']}>
1826
<ul>
1927
{Array.from(streams).map(([id, stream]) => (
2028
<li key={id}>
21-
<ConfMedia key={id} stream={stream} muted={id === 'me' ? true : false} />
29+
<ConfMedia
30+
key={id}
31+
stream={stream}
32+
muted={id === 'me' ? true : false}
33+
/>
2234
<StreamButton
2335
isMicOn={false}
2436
isCamOn={true} // TODO: μž„μ‹œλ‘œ μ§€μ •

β€Žclient/src/components/Mom/Block/index.tsxβ€Ž

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
RemoteDeleteOperation,
44
} from '@wabinar/crdt/linked-list';
55
import { useEffect, useRef, memo } from 'react';
6+
import SOCKET_MESSAGE from 'src/constants/socket-message';
67
import { useCRDT } from 'src/hooks/useCRDT';
78
import { useOffset } from 'src/hooks/useOffset';
89
import useSocketContext from 'src/hooks/useSocketContext';
@@ -44,7 +45,7 @@ function Block({ id, onKeyDown, index }: BlockProps) {
4445
if (event.inputType === 'deleteContentBackward') {
4546
const remoteDeletion = localDeleteCRDT(offsetRef.current);
4647

47-
socket.emit('text-deletion', id, remoteDeletion);
48+
socket.emit(SOCKET_MESSAGE.BLOCK.DELETE_TEXT, id, remoteDeletion);
4849
return;
4950
}
5051

@@ -54,7 +55,7 @@ function Block({ id, onKeyDown, index }: BlockProps) {
5455

5556
const remoteInsertion = localInsertCRDT(previousLetterIndex, letter);
5657

57-
socket.emit('text-insertion', id, remoteInsertion);
58+
socket.emit(SOCKET_MESSAGE.BLOCK.INSERT_TEXT, id, remoteInsertion);
5859
};
5960

6061
// 리λͺ¨νŠΈ μ—°μ‚° μˆ˜ν–‰κ²°κ³Όλ‘œ innerText λ³€κ²½ μ‹œ μ»€μ„œμ˜ μœ„μΉ˜ μ‘°μ •
@@ -89,7 +90,7 @@ function Block({ id, onKeyDown, index }: BlockProps) {
8990

9091
// crdt의 μ΄ˆκΈ°ν™”μ™€ μ†ŒμΌ“μ„ 톡해 μ „λ‹¬λ°›λŠ” 리λͺ¨νŠΈ μ—°μ‚° 처리
9192
useEffect(() => {
92-
socket.emit('block-initialization', id);
93+
socket.emit(SOCKET_MESSAGE.BLOCK.INIT, id);
9394

9495
const onInitialize = (crdt: unknown) => {
9596
syncCRDT(crdt);
@@ -124,14 +125,14 @@ function Block({ id, onKeyDown, index }: BlockProps) {
124125
updateCaretPosition(-Number(targetIndex <= offsetRef.current));
125126
};
126127

127-
ee.on(`block-initialization-${id}`, onInitialize);
128-
ee.on(`text-insertion-${id}`, onInsert);
129-
ee.on(`text-deletion-${id}`, onDelete);
128+
ee.on(`${SOCKET_MESSAGE.BLOCK.INIT}-${id}`, onInitialize);
129+
ee.on(`${SOCKET_MESSAGE.BLOCK.INSERT_TEXT}-${id}`, onInsert);
130+
ee.on(`${SOCKET_MESSAGE.BLOCK.DELETE_TEXT}-${id}`, onDelete);
130131

131132
return () => {
132-
ee.off(`block-initialization-${id}`, onInitialize);
133-
ee.off(`text-insertion-${id}`, onInsert);
134-
ee.off(`text-deletion-${id}`, onDelete);
133+
ee.off(`${SOCKET_MESSAGE.BLOCK.INIT}-${id}`, onInitialize);
134+
ee.off(`${SOCKET_MESSAGE.BLOCK.INSERT_TEXT}-${id}`, onInsert);
135+
ee.off(`${SOCKET_MESSAGE.BLOCK.DELETE_TEXT}-${id}`, onDelete);
135136
};
136137
}, []);
137138

@@ -161,6 +162,7 @@ function Block({ id, onKeyDown, index }: BlockProps) {
161162
return (
162163
<p
163164
ref={blockRef}
165+
data-id={id}
164166
data-index={index}
165167
onInput={onInput}
166168
onCompositionEnd={onCompositionEnd}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import GuideIcon from 'src/components/common/GuideIcon';
3+
import AmazedWabIcon from 'src/components/common/Icon/Wab/AmazedWabIcon';
4+
5+
import style from './style.module.scss';
6+
7+
function DefaultMom() {
8+
return (
9+
<div className={style['default-container']}>
10+
<AmazedWabIcon />
11+
<h1 className={style.message}>회의둝이 ν……ν…… λΉ„μ—ˆμ–΄μš”.</h1>
12+
<GuideIcon>
13+
<p>
14+
μ‚¬μ΄λ“œλ°”μ—μ„œ <span className={style.highlight}>+ 회의둝 μΆ”κ°€</span>{' '}
15+
λ²„νŠΌμ„ 클릭해 νšŒμ˜λ‘μ„ μΆ”κ°€ν•΄ λ³΄μ„Έμš”!
16+
</p>
17+
</GuideIcon>
18+
</div>
19+
);
20+
}
21+
22+
export default DefaultMom;

0 commit comments

Comments
Β (0)