File tree Expand file tree Collapse file tree 4 files changed +32
-5
lines changed Expand file tree Collapse file tree 4 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import { socketEmit } from '@api/socket.api';
3030import { SOCKET_EVENT_TYPE } from '@constants/socket.constant' ;
3131import useSafeNavigate from '@hooks/useSafeNavigate' ;
3232import { PAGE_TYPE } from '@constants/page.constant' ;
33+ import useCleanupRoom from '@hooks/useCleanupRoom' ;
3334
3435interface Props {
3536 mainController ?: React . ReactNode ;
@@ -43,6 +44,7 @@ enum DRAWER_TYPE {
4344
4445const BottomBar = ( { mainController } : Props ) => {
4546 const { safeNavigate } = useSafeNavigate ( ) ;
47+ const cleanupRoom = useCleanupRoom ( ) ;
4648 const [ isMicOn , setIsMicOn ] = useState ( true ) ;
4749 const [ isCameraOn , setIsCameraOn ] = useState ( true ) ;
4850
@@ -78,6 +80,7 @@ const BottomBar = ({ mainController }: Props) => {
7880
7981 const handleLeaveRoom = ( ) => {
8082 socketEmit ( SOCKET_EVENT_TYPE . LEAVE_ROOM ) ;
83+ cleanupRoom ( ) ;
8184 safeNavigate ( PAGE_TYPE . LANDING_PAGE ) ;
8285 } ;
8386
Original file line number Diff line number Diff line change 1+ import { meInRoomState , othersInRoomState , roomUUIDState } from '@store/room.store' ;
2+ import { webRTCUserMapState } from '@store/webRTC.store' ;
3+ import { useCallback } from 'react' ;
4+ import { useResetRecoilState } from 'recoil' ;
5+ import useCleanupInterview from './useCleanupInterview' ;
6+
7+ const useCleanupRoom = ( ) => {
8+ const cleanupInterview = useCleanupInterview ( ) ;
9+ const roomUUIDRefresher = useResetRecoilState ( roomUUIDState ) ;
10+ const ohtersRefresher = useResetRecoilState ( othersInRoomState ) ;
11+ const meRefresher = useResetRecoilState ( meInRoomState ) ;
12+ const webRTCUserMapRefresher = useResetRecoilState ( webRTCUserMapState ) ;
13+
14+ const cleanupRoom = useCallback ( ( ) => {
15+ console . log ( 'cleanup room' ) ;
16+ roomUUIDRefresher ( ) ;
17+ ohtersRefresher ( ) ;
18+ meRefresher ( ) ;
19+ webRTCUserMapRefresher ( ) ;
20+
21+ cleanupInterview ( ) ;
22+ } , [ ] ) ;
23+
24+ return cleanupRoom ;
25+ } ;
26+
27+ export default useCleanupRoom ;
Original file line number Diff line number Diff line change @@ -25,15 +25,12 @@ interface joinInterviewResponseType {
2525}
2626
2727const Lobby = ( ) => {
28+ usePreventLeave ( ) ;
2829 const { safeNavigate } = useSafeNavigate ( ) ;
2930 const [ me , setMe ] = useRecoilState < UserType > ( meInRoomState ) ;
3031 const [ others , setOthers ] = useRecoilState < UserType [ ] > ( othersInRoomState ) ;
31-
32- usePreventLeave ( ) ;
33-
3432 const [ webRTCUserList , setWebRTCUserList ] = useRecoilState ( webRTCUserMapState ) ;
3533 const { startConnection } = useWebRTCSignaling ( webRTCUserList , setWebRTCUserList ) ;
36-
3734 const streamList = useRecoilValue ( webRTCStreamSelector ) ;
3835
3936 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 11import { io } from 'socket.io-client' ;
22
3- export const socket = io ( '/socket' ) ;
3+ export const socket = io ( '/socket' ) ;
You can’t perform that action at this time.
0 commit comments