Skip to content

Commit

Permalink
merge: [FIX] 방장이 자신의 방이 아닌 다른 방의 방장 권한을 얻게 되는 버그 수정 (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
novice0840 authored Dec 13, 2024
2 parents 7e136f7 + 147afc8 commit 5a6b0e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/hooks/useGetUserInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query';
import { useParams } from 'react-router-dom';
import { useParams, useNavigate } from 'react-router-dom';

import { getUserInfo } from '@/apis/room';
import { QUERY_KEYS } from '@/constants/queryKeys';
Expand All @@ -9,13 +9,17 @@ const USER_INFO_STALE_TIME = 2 * 60 * 60 * 1000;

const useGetUserInfo = (): RoomAndMember => {
const { roomId } = useParams();

const navigate = useNavigate();
const { data } = useQuery({
queryKey: [QUERY_KEYS.getUserInfo, roomId],
queryFn: getUserInfo,
staleTime: USER_INFO_STALE_TIME,
});

if (Number(roomId) !== data?.roomId) {
navigate('/', { replace: true });
}

return {
roomId: data?.roomId || 0,
roomUuid: data?.roomUuid || '',
Expand Down

0 comments on commit 5a6b0e4

Please sign in to comment.