Skip to content

Commit

Permalink
Add the isfetching check
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabau committed Nov 13, 2023
1 parent 0832792 commit 7320497
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pages/collab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const MatchRequestPage = () => {
const { data: numOfOnlineUsers = 0, refetch: refetchGetNumOfMatchReqs } =
api.matchRequest.getNumOfMatchRequests.useQuery();

const { data: curUserMatchRequest, refetch: refetchCurrentUserRequest } =
const { data: curUserMatchRequest, refetch: refetchCurrentUserRequest, isFetching: isCurUserMatchFetching } =
api.matchRequest.getCurrentUserRequest.useQuery(undefined, {
onError() {
toast.error("Error loading current user's match request");
Expand Down Expand Up @@ -145,8 +145,7 @@ const MatchRequestPage = () => {


useEffect(() => {
if (time >= REQUEST_EXPIRY_TIME_SECS && curUserMatchRequest) {
console.log(curUserMatchRequest);
if (time >= REQUEST_EXPIRY_TIME_SECS && curUserMatchRequest && !isCurUserMatchFetching) {
const { difficulty, category, matchType } = curUserMatchRequest;
const sameRequest = { difficulty, category, matchType };
deleteMatchRequest({ matchType: curUserMatchRequest.matchType });
Expand Down Expand Up @@ -178,7 +177,7 @@ const MatchRequestPage = () => {
{ duration: 60000, id: "timeout", position: "top-center" },
);
}
}, [time]);
}, [time, curUserMatchRequest]);

useEffect(() => {
if (!curUserMatchRequest) {
Expand Down

0 comments on commit 7320497

Please sign in to comment.