Skip to content

Commit

Permalink
refactor: AiSummary 컴포넌트에서 socket 변수를 함수 내로 이동 및 타입 정의 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seoko97 committed Dec 4, 2024
1 parent a1aa4de commit 7d962df
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apps/web/src/components/live/SettingDialog/AiSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@ import { SOCKET_EVENTS } from '@repo/mediasoup';
import Button from '@/components/common/Button';
import { useMediasoupState } from '@/contexts/mediasoup/context';

interface GetIsRecordingRes {
isRecording: boolean;
}

function AiSummary() {
const [isRecording, setIsRecording] = useState<boolean>(false);
const { socketRef } = useMediasoupState();
const socket = socketRef.current;
const { ticleId: roomId } = useParams({ from: '/_authenticated/live/$ticleId' });

const handleRecordStart = () => {
const socket = socketRef.current;

if (!socket) return;

socket.emit(SOCKET_EVENTS.startRecord, { roomId });
setIsRecording(true);
};

useEffect(() => {
const socket = socketRef.current;

if (!socket) return;
socket.emit(SOCKET_EVENTS.getIsRecording, { roomId }, (res) => {
const { isRecording } = res;

socket.emit(SOCKET_EVENTS.getIsRecording, { roomId }, (data: GetIsRecordingRes) => {
const { isRecording } = data;

setIsRecording(isRecording);
});
}, []);
Expand Down

0 comments on commit 7d962df

Please sign in to comment.