Conversation
- useGetStudyHandwriting: publishId/problemId 기반 필기 조회 hook - useUpdateStudyHandwriting: 필기 저장 mutation + setQueryData 캐시 즉시 반영 - study/index.ts: 새 hook export 추가 - schema.d.ts: openapi 타입 재생성 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a new student study handwriting API layer to the native app so problem-solving/pointing screens can fetch and persist handwriting tied to (publishId, problemId) using the existing OpenAPI + TanStack Query client setup.
Changes:
- Added
useGetStudyHandwritingquery hook for fetching handwriting withstaleTime: Infinityandenabledsupport. - Added
useUpdateStudyHandwritingmutation hook to save/update handwriting and immediately update the query cache. - Regenerated OpenAPI types (
schema.d.ts) and exported the new hooks from the study controller index.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/native/src/types/api/schema.d.ts | Adds Study handwriting endpoint types (and other regenerated schema changes). |
| apps/native/src/apis/controller/student/study/index.ts | Exposes new handwriting hooks from the study controller entrypoint. |
| apps/native/src/apis/controller/student/study/handwriting/useGetStudyHandwriting.ts | New query hook for (publishId, problemId) handwriting retrieval. |
| apps/native/src/apis/controller/student/study/handwriting/putUpdateStudyHandwriting.ts | New mutation hook for saving handwriting + updating cached query data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| onSuccess: (_, { publishId, problemId, request }) => { | ||
| queryClient.setQueryData( | ||
| TanstackQueryClient.queryOptions( | ||
| 'get', | ||
| '/api/student/study/problem/{publishId}/{problemId}/handwriting', | ||
| { | ||
| params: { path: { publishId, problemId } }, | ||
| } | ||
| ).queryKey, | ||
| { data: request.data } | ||
| ); |
There was a problem hiding this comment.
onSuccess updates the handwriting query cache with { data: request.data }, which does not match the query’s response type (StudyHandwritingResp includes publishId, problemId, and optionally updatedAt). This can leave the cache in an inconsistent shape and break consumers that expect those fields. Update the cache with the actual mutation response (or merge with existing cached value while preserving required fields).
| }, | ||
| { | ||
| enabled, | ||
| staleTime: Infinity, |
There was a problem hiding this comment.
This query sets staleTime: Infinity but omits gcTime: Infinity, unlike other study hooks (e.g. useGetProblem) that keep these caches from being garbage-collected. With the default gcTime, handwriting may be evicted after inactivity and refetched unexpectedly. Consider setting gcTime: Infinity here as well to align with the surrounding study query caching strategy.
| staleTime: Infinity, | |
| staleTime: Infinity, | |
| gcTime: Infinity, |
Summary
문제 풀기/포인팅 화면에서 필기 저장을 위한 study handwriting API hook을 추가합니다.
Linear
Changes
staleTime: Infinity,enabled패턴)setQueryData로 캐시 즉시 반영pnpm openapi재생성 (study handwriting 엔드포인트 타입 포함)Testing
pnpm typecheck)Risk / Impact