fix: 학습 알림톡 시간 저장 연결#679
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthrough알림 설정 쿼리 훅의 타입과 쿼리 키를 공개하고, 캐시 갱신 방식을 Changes알림 설정 상태 관리 및 로딩 상태 반영
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/queries/notification/use-notification-setting.ts`:
- Around line 39-43: The onSuccess currently replaces the whole cache via
queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data) which can
overwrite optional/partial fields and cause UI flicker; instead, in the
onSuccess handler for useNotificationSetting merge incoming data with existing
cache (read existing via
queryClient.getQueryData(NOTIFICATION_SETTING_QUERY_KEY) or use setQueryData(old
=> ...)) and shallow-merge/assign only provided fields (e.g., merge isEnabled
and other optional properties) before writing back, then call
queryClient.invalidateQueries for NOTIFICATION_SETTING_QUERY_KEY if needed;
update the onSuccess in use-notification-setting.ts to perform this merge logic
so partial responses don’t clobber missing fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3fcb0779-6f0d-4bb8-8b5a-f374f52905c4
📒 Files selected for processing (3)
src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsxsrc/app/(service)/(my)/my-class/page.tsxsrc/hooks/queries/notification/use-notification-setting.ts
| onSuccess: async (data) => { | ||
| queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data); | ||
| await queryClient.invalidateQueries({ | ||
| queryKey: NOTIFICATION_SETTING_QUERY_KEY, | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "1) notification-setting 관련 타입/사용처 확인"
rg -n --type=ts -C3 "NotificationSettingResponse|isEnabled|saved|members/me/notification-setting|setQueryData\\(|useGetNotificationSetting\\("
echo
echo "2) OpenAPI/Swagger 산출물(있다면)에서 notification-setting 응답 스키마 확인"
fd -i "openapi|swagger" .Repository: code-zero-to-one/study-platform-client
Length of output: 39137
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) use-notification-setting.ts 관련 코드 ==="
sed -n '1,120p' src/hooks/queries/notification/use-notification-setting.ts
echo
echo "=== 2) my-class page.tsx에서 notificationSetting 소비부 ==="
sed -n '1,220p' src/app/(service)/(my)/my-class/page.tsx
echo
echo "=== 3) learning-notification-modal.tsx에서 소비부 ==="
sed -n '1,200p' "src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx"
echo
echo "=== 4) notification-setting 관련 API/스키마(가능하면) 추가 탐색 ==="
rg -n "notification-setting" src | head -n 50
echo
echo "=== 5) NotificationSettingResponse/saved 사용처 ==="
rg -n "NotificationSettingResponse|\\.saved\\b|isEnabled\\b" src/app src/features src/hooks/queries/notification | head -n 80Repository: code-zero-to-one/study-platform-client
Length of output: 1626
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) use-notification-setting.ts 관련 코드 ==="
sed -n '1,120p' src/hooks/queries/notification/use-notification-setting.ts
echo
echo "=== 2) my-class page.tsx에서 notificationSetting 소비부 ==="
sed -n '1,220p' src/app/(service)/(my)/my-class/page.tsx
echo
echo "=== 3) learning-notification-modal.tsx에서 소비부 ==="
sed -n '1,200' "src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx"
echo
echo "=== 4) notification-setting 관련 API/스키마(가능하면) 추가 탐색 ==="
rg -n "notification-setting" src | head -n 50
echo
echo "=== 5) NotificationSettingResponse/saved 사용처 ==="
rg -n "NotificationSettingResponse|\\.saved\\b|isEnabled\\b" src/app src/features src/hooks/queries/notification | head -n 80Repository: code-zero-to-one/study-platform-client
Length of output: 1626
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) my-class page.tsx에서 notificationSetting 소비부 핵심 ==="
sed -n '1,90p' "src/app/(service)/(my)/my-class/page.tsx"
echo
echo "=== 2) learning-notification-modal.tsx에서 notificationSetting 소비부 핵심 ==="
sed -n '1,140p' "src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx"
echo
echo "=== 3) NotificationSettingResponse(타입) 직접 사용/필드 접근 추가 탐색 ==="
rg -n "NotificationSettingResponse|notificationSetting\\?\\.isEnabled|\\bisEnabled\\b|\\bsaved\\b" \
"src/app/(service)/(my)/my-class" src/features/mentoring src/hooks/queries/notification
echo
echo "=== 4) notification-setting query key 사용처(캐시 참조) ==="
rg -n "NOTIFICATION_SETTING_QUERY_KEY|notification-setting" src/hooks src/appRepository: code-zero-to-one/study-platform-client
Length of output: 11114
src/hooks/queries/notification/use-notification-setting.ts 캐시 업데이트를 부분 응답에 대비해 병합하세요
onSuccess에서 queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data)로 통째 교체하면 NotificationSettingResponse가 optional 필드(isEnabled 등)만 부분 포함하는 경우, my-class/page.tsx에서 notificationSetting?.isEnabled ?? false 때문에 토글 상태가 잠깐 잘못(깜빡임) 표시될 수 있습니다.
🔧 제안 수정안
- onSuccess: async (data) => {
- queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data);
+ onSuccess: async (data) => {
+ queryClient.setQueryData(
+ NOTIFICATION_SETTING_QUERY_KEY,
+ (prev?: NotificationSettingResponse) => ({
+ ...prev,
+ ...data,
+ }),
+ );
await queryClient.invalidateQueries({
queryKey: NOTIFICATION_SETTING_QUERY_KEY,
});
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onSuccess: async (data) => { | |
| queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data); | |
| await queryClient.invalidateQueries({ | |
| queryKey: NOTIFICATION_SETTING_QUERY_KEY, | |
| }); | |
| onSuccess: async (data) => { | |
| queryClient.setQueryData( | |
| NOTIFICATION_SETTING_QUERY_KEY, | |
| (prev?: NotificationSettingResponse) => ({ | |
| ...prev, | |
| ...data, | |
| }), | |
| ); | |
| await queryClient.invalidateQueries({ | |
| queryKey: NOTIFICATION_SETTING_QUERY_KEY, | |
| }); | |
| }, |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/hooks/queries/notification/use-notification-setting.ts` around lines 39 -
43, The onSuccess currently replaces the whole cache via
queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data) which can
overwrite optional/partial fields and cause UI flicker; instead, in the
onSuccess handler for useNotificationSetting merge incoming data with existing
cache (read existing via
queryClient.getQueryData(NOTIFICATION_SETTING_QUERY_KEY) or use setQueryData(old
=> ...)) and shallow-merge/assign only provided fields (e.g., merge isEnabled
and other optional properties) before writing back, then call
queryClient.invalidateQueries for NOTIFICATION_SETTING_QUERY_KEY if needed;
update the onSuccess in use-notification-setting.ts to perform this merge logic
so partial responses don’t clobber missing fields.
요약
검증
범위
Summary by CodeRabbit
릴리스 노트