@@ -13,7 +13,7 @@ import {
13
13
} from "../utils/constants" ;
14
14
import { useAuth } from "./AuthContext" ;
15
15
import { toast } from "react-toastify" ;
16
- import { useAppNavigate } from "../components/NoDirectAccessRoutes " ;
16
+ import useAppNavigate from "../components/UseAppNavigate " ;
17
17
18
18
type MatchUser = {
19
19
id : string ;
@@ -98,7 +98,8 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
98
98
throw new Error ( USE_AUTH_ERROR_MESSAGE ) ;
99
99
}
100
100
const { user } = auth ;
101
- const [ matchUser , _setMatchUser ] = useState < MatchUser | null > (
101
+
102
+ const [ matchUser ] = useState < MatchUser | null > (
102
103
user
103
104
? {
104
105
id : user . id ,
@@ -136,6 +137,7 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
136
137
closeSocketConnection ( ) ;
137
138
window . removeEventListener ( "beforeunload" , ( ) => closeSocketConnection ( ) ) ;
138
139
} ;
140
+ // eslint-disable-next-line react-hooks/exhaustive-deps
139
141
} , [ matchUser ?. id , location . pathname ] ) ;
140
142
141
143
const resetMatchStates = ( ) => {
@@ -220,7 +222,11 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
220
222
const initMatchRequestListeners = ( ) => {
221
223
matchSocket . on ( MatchEvents . MATCH_FOUND , ( { matchId, user1, user2 } ) => {
222
224
setMatchId ( matchId ) ;
223
- matchUser ?. id === user1 . id ? setPartner ( user2 ) : setPartner ( user1 ) ;
225
+ if ( matchUser ?. id === user1 . id ) {
226
+ setPartner ( user2 ) ;
227
+ } else {
228
+ setPartner ( user1 ) ;
229
+ }
224
230
setMatchPending ( true ) ;
225
231
appNavigate ( MatchPaths . MATCHED ) ;
226
232
} ) ;
@@ -237,7 +243,11 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
237
243
const initMatchingListeners = ( ) => {
238
244
matchSocket . on ( MatchEvents . MATCH_FOUND , ( { matchId, user1, user2 } ) => {
239
245
setMatchId ( matchId ) ;
240
- matchUser ?. id === user1 . id ? setPartner ( user2 ) : setPartner ( user1 ) ;
246
+ if ( matchUser ?. id === user1 . id ) {
247
+ setPartner ( user2 ) ;
248
+ } else {
249
+ setPartner ( user1 ) ;
250
+ }
241
251
setMatchPending ( true ) ;
242
252
appNavigate ( MatchPaths . MATCHED ) ;
243
253
} ) ;
@@ -256,7 +266,11 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
256
266
257
267
matchSocket . on ( MatchEvents . MATCH_FOUND , ( { matchId, user1, user2 } ) => {
258
268
setMatchId ( matchId ) ;
259
- matchUser ?. id === user1 . id ? setPartner ( user2 ) : setPartner ( user1 ) ;
269
+ if ( matchUser ?. id === user1 . id ) {
270
+ setPartner ( user2 ) ;
271
+ } else {
272
+ setPartner ( user1 ) ;
273
+ }
260
274
setMatchPending ( true ) ;
261
275
appNavigate ( MatchPaths . MATCHED ) ;
262
276
} ) ;
0 commit comments