Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { client } from '@/apis/client';
import { client, TanstackQueryClient } from '@/apis/client';

export const useDeleteHandwriting = () => {
const queryClient = useQueryClient();
Expand All @@ -14,8 +14,18 @@ export const useDeleteHandwriting = () => {
});
},
onSuccess: (_, scrapId) => {
queryClient.invalidateQueries({ queryKey: ['scrap', 'handwriting', scrapId] });
queryClient.invalidateQueries({ queryKey: ['scrap', 'detail', scrapId] });
queryClient.invalidateQueries({
queryKey: TanstackQueryClient.queryOptions(
'get',
'/api/student/scrap/{scrapId}/handwriting',
{ params: { path: { scrapId } } }
).queryKey,
});
queryClient.invalidateQueries({
queryKey: TanstackQueryClient.queryOptions('get', '/api/student/scrap/{id}', {
params: { path: { id: scrapId } },
}).queryKey,
});
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ export const useUpdateHandwriting = () => {
});
return data as UpdateHandwritingResponse;
},
// onSuccess: (_, { scrapId }) => {
// queryClient.invalidateQueries({
// queryKey: TanstackQueryClient.queryOptions(
// 'get',
// '/api/student/scrap/{scrapId}/handwriting',
// { params: { path: { scrapId } } }
// ).queryKey,
// });
// },
onSuccess: (response, { scrapId }) => {
queryClient.setQueryData(
TanstackQueryClient.queryOptions('get', '/api/student/scrap/{scrapId}/handwriting', {
params: { path: { scrapId } },
}).queryKey,
response
);
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const useGetHandwriting = (scrapId: number, enabled = true) => {
},
{
enabled,
staleTime: Infinity,
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staleTime: Infinity로 인해 이 쿼리는 기본적으로 더 이상 stale 상태가 되지 않아, 이후 데이터 변경은 mutation에서 setQueryData/invalidateQueries로 보장해야 합니다. 현재 useDeleteHandwriting['scrap','handwriting',scrapId] 형태의 queryKey를 invalidate하고 있어(openapi-react-query TanstackQueryClient.useQuery의 queryKey와 불일치), 삭제 후에도 이 캐시가 남을 수 있습니다. handwriting 관련 mutation들이 모두 TanstackQueryClient.queryOptions(...).queryKey를 사용하도록 정리하거나, 삭제 시 해당 queryKey에 대해 setQueryData(undefined)/invalidate를 해 주세요.

Suggested change
staleTime: Infinity,

Copilot uses AI. Check for mistakes.
refetchOnWindowFocus: false,
}
);
};
Loading