Skip to content

Commit fd2a2d2

Browse files
committed
fix linting error
1 parent f9498b0 commit fd2a2d2

File tree

2 files changed

+17
-33
lines changed

2 files changed

+17
-33
lines changed

backend/matching-service/src/handlers/websocketHandler.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,24 @@ export const handleWebsocketMatchEvents = (socket: Socket) => {
119119
userConnections.delete(uid);
120120
});
121121

122-
socket.on(
123-
MatchEvents.MATCH_ACCEPT_REQUEST,
124-
(matchId: string, userId1: string, userId2: string) => {
125-
const partnerAccepted = handleMatchAccept(matchId);
126-
if (partnerAccepted) {
127-
const match = getMatchById(matchId);
128-
if (!match) {
129-
return;
130-
}
131-
132-
const { complexity, category } = match;
133-
getRandomQuestion(complexity, category).then((res) => {
134-
io.to(matchId).emit(
135-
MatchEvents.MATCH_SUCCESSFUL,
136-
res.data.question.id,
137-
res.data.question.title
138-
);
139-
});
122+
socket.on(MatchEvents.MATCH_ACCEPT_REQUEST, (matchId: string) => {
123+
const partnerAccepted = handleMatchAccept(matchId);
124+
if (partnerAccepted) {
125+
const match = getMatchById(matchId);
126+
if (!match) {
127+
return;
140128
}
129+
130+
const { complexity, category } = match;
131+
getRandomQuestion(complexity, category).then((res) => {
132+
io.to(matchId).emit(
133+
MatchEvents.MATCH_SUCCESSFUL,
134+
res.data.question.id,
135+
res.data.question.title
136+
);
137+
});
141138
}
142-
);
139+
});
143140

144141
socket.on(
145142
MatchEvents.MATCH_DECLINE_REQUEST,

frontend/src/contexts/MatchContext.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ import useAppNavigate from "../hooks/useAppNavigate";
1717
import { UNSAFE_NavigationContext } from "react-router-dom";
1818
import { Action, type History, type Transition } from "history";
1919

20-
let matchUserId: string;
21-
let partnerUserId: string;
22-
2320
type MatchUser = {
2421
id: string;
2522
username: string;
@@ -126,10 +123,8 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
126123
username: user.username,
127124
profile: user.profilePictureUrl,
128125
});
129-
matchUserId = user.id;
130126
} else {
131127
setMatchUser(null);
132-
matchUserId = "";
133128
}
134129
}, [user]);
135130

@@ -183,7 +178,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
183178
}
184179
setMatchId(null);
185180
setPartner(null);
186-
partnerUserId = "";
187181
setMatchPending(false);
188182
setLoading(false);
189183
};
@@ -307,10 +301,8 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
307301
setMatchId(matchId);
308302
if (matchUser?.id === user1.id) {
309303
setPartner(user2);
310-
partnerUserId = user2.id;
311304
} else {
312305
setPartner(user1);
313-
partnerUserId = user1.id;
314306
}
315307
setMatchPending(true);
316308
appNavigate(MatchPaths.MATCHED);
@@ -391,9 +383,7 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
391383
const acceptMatch = () => {
392384
matchSocket.emit(
393385
MatchEvents.MATCH_ACCEPT_REQUEST,
394-
matchId,
395-
matchUserId,
396-
partnerUserId
386+
matchId
397387
);
398388
};
399389

@@ -429,7 +419,6 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
429419
if (requested) {
430420
appNavigate(MatchPaths.MATCHING);
431421
setPartner(null);
432-
partnerUserId = "";
433422
}
434423
}
435424
);
@@ -479,11 +468,9 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
479468
if (match) {
480469
setMatchId(match.matchId);
481470
setPartner(match.partner);
482-
partnerUserId = match.partner.id;
483471
} else {
484472
setMatchId(null);
485473
setPartner(null);
486-
partnerUserId = "";
487474
}
488475
setLoading(false);
489476
}

0 commit comments

Comments
 (0)