Skip to content

Commit

Permalink
캐싱 문제, 토큰 문제 해결 (#664)
Browse files Browse the repository at this point in the history
* refactor: trip api명세 변경으로 인한 코드 수정

* refactor: 커뮤니티 페이지 디자인 변경

* fix: 토큰버그수정, 캐싱문제 수정 =>cachetime =0

* refactor:불필요한 코드 제거
  • Loading branch information
Dahyeeee authored Oct 6, 2023
1 parent 67ec639 commit 7e573c8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion frontend/src/api/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const handleTokenError = async (error: AxiosError<ErrorResponseData>) =>
data.code === ERROR_CODE.INVALID_TOKEN_VALIDATE ||
data.code === ERROR_CODE.NULL_REFRESH_TOKEN ||
data.code === ERROR_CODE.UNEXPECTED_TOKEN_ERROR ||
data.code === ERROR_CODE.UNAUTHORIZED)
data.code === ERROR_CODE.UNAUTHORIZED ||
data.code === ERROR_CODE.INVALID_ACCESS_TOKEN)
) {
localStorage.removeItem(ACCESS_TOKEN_KEY);

Expand Down
8 changes: 6 additions & 2 deletions frontend/src/hooks/api/useCommunityTripQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import type { TripData } from '@type/trip';
export const useCommunityTripQuery = (tripId: string) => {
const isLoggedIn = useRecoilValue(isLoggedInState);

const { data } = useQuery<TripData, AxiosError>(['PUBLISHED', tripId], () =>
getCommunityTrip(tripId, isLoggedIn)
const { data } = useQuery<TripData, AxiosError>(
['PUBLISHED', tripId],
() => getCommunityTrip(tripId, isLoggedIn),
{
cacheTime: 0,
}
);

return { tripData: data! };
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/hooks/api/useLikeMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useLikeMutation = () => {
const likeMutation = useMutation({
mutationFn: postLike,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['communityTrips', 1] });
queryClient.invalidateQueries({ queryKey: ['communityTrips'] });
queryClient.invalidateQueries({ queryKey: ['recommendedTrips'] });
},
onError: (error: ErrorResponseData) => {
Expand All @@ -28,6 +28,7 @@ export const useLikeMutation = () => {
if (error.code && error.code > ERROR_CODE.TOKEN_ERROR_RANGE) {
handleTokenError();
}

createToast('오류가 발생했습니다. 다시 시도해 주세요.');
},
});
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/hooks/api/useRecommendedTripsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import { getRecommendedTrips } from '@api/trips/getRecommendedTrips';
import type { RecommendedTripsData } from '@type/trips';

export const useRecommendedTripsQuery = (isLoggedIn: boolean) => {
const { data } = useQuery<RecommendedTripsData, AxiosError>(['recommendedTrips'], () =>
getRecommendedTrips(isLoggedIn)
const { data } = useQuery<RecommendedTripsData, AxiosError>(
['recommendedTrips'],
() => getRecommendedTrips(isLoggedIn),
{
cacheTime: 0,
}
);

return { tripsData: data! };
Expand Down

0 comments on commit 7e573c8

Please sign in to comment.