6
6
ABORT_MATCH_PROCESS_CONFIRMATION_MESSAGE ,
7
7
FAILED_MATCH_REQUEST_MESSAGE ,
8
8
MATCH_CONNECTION_ERROR ,
9
- MATCH_ENDED_MESSAGE ,
10
9
MATCH_LOGIN_REQUIRED_MESSAGE ,
11
10
MATCH_REQUEST_EXISTS_MESSAGE ,
12
11
MATCH_UNSUCCESSFUL_MESSAGE ,
@@ -18,9 +17,6 @@ import useAppNavigate from "../components/UseAppNavigate";
18
17
import { UNSAFE_NavigationContext } from "react-router-dom" ;
19
18
import { Action , type History , type Transition } from "history" ;
20
19
21
- import { useReducer } from "react" ;
22
- import qnHistoryReducer , { initialQHState } from "../reducers/qnHistoryReducer" ;
23
-
24
20
let matchUserId : string ;
25
21
let partnerUserId : string ;
26
22
@@ -54,7 +50,6 @@ enum MatchEvents {
54
50
MATCH_FOUND = "match_found" ,
55
51
MATCH_SUCCESSFUL = "match_successful" ,
56
52
MATCH_UNSUCCESSFUL = "match_unsuccessful" ,
57
- MATCH_ENDED = "match_ended" ,
58
53
MATCH_REQUEST_EXISTS = "match_request_exists" ,
59
54
MATCH_REQUEST_ERROR = "match_request_error" ,
60
55
@@ -93,8 +88,6 @@ type MatchContextType = {
93
88
partner : MatchUser | null ;
94
89
matchPending : boolean ;
95
90
loading : boolean ;
96
- isEndSessionModalOpen : boolean ;
97
- setIsEndSessionModalOpen : React . Dispatch < React . SetStateAction < boolean > > ;
98
91
questionId : string | null ;
99
92
qnHistoryId : string | null ;
100
93
} ;
@@ -124,15 +117,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
124
117
const [ questionId , setQuestionId ] = useState < string | null > ( null ) ;
125
118
const [ qnHistoryId , setQnHistoryId ] = useState < string | null > ( null ) ;
126
119
127
- const [ isEndSessionModalOpen , setIsEndSessionModalOpen ] =
128
- useState < boolean > ( false ) ;
129
-
130
- // eslint-disable-next-line
131
- const [ qnHistoryState , qnHistoryDispatch ] = useReducer (
132
- qnHistoryReducer ,
133
- initialQHState
134
- ) ;
135
-
136
120
const navigator = useContext ( UNSAFE_NavigationContext ) . navigator as History ;
137
121
138
122
useEffect ( ( ) => {
@@ -233,9 +217,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
233
217
case MatchPaths . MATCHED :
234
218
initMatchedListeners ( ) ;
235
219
return ;
236
- case MatchPaths . COLLAB :
237
- initCollabListeners ( ) ;
238
- return ;
239
220
default :
240
221
return ;
241
222
}
@@ -318,14 +299,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
318
299
} ) ;
319
300
} ;
320
301
321
- const initCollabListeners = ( ) => {
322
- matchSocket . on ( MatchEvents . MATCH_ENDED , ( ) => {
323
- toast . error ( MATCH_ENDED_MESSAGE ) ;
324
- setIsEndSessionModalOpen ( false ) ;
325
- appNavigate ( MatchPaths . HOME ) ;
326
- } ) ;
327
- } ;
328
-
329
302
const handleMatchFound = (
330
303
matchId : string ,
331
304
user1 : MatchUser ,
@@ -409,7 +382,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
409
382
return ;
410
383
case MatchPaths . COLLAB :
411
384
matchSocket . emit ( MatchEvents . MATCH_END_REQUEST , matchUser ?. id , matchId ) ;
412
- appNavigate ( MatchPaths . HOME ) ;
413
385
return ;
414
386
default :
415
387
return ;
@@ -539,8 +511,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
539
511
partner,
540
512
matchPending,
541
513
loading,
542
- isEndSessionModalOpen,
543
- setIsEndSessionModalOpen,
544
514
questionId,
545
515
qnHistoryId,
546
516
} }
0 commit comments