Skip to content

Conversation

@minimo-9
Copy link
Contributor

@minimo-9 minimo-9 commented Aug 3, 2025

📌 변경 사항 개요

알람 api 수정

📝 상세 내용

로그인하지 않은 상태에서 알림 API 반복 요청으로 401 에러 발생 문제 해결

🔗 관련 이슈

🖼️ 스크린샷(선택사항)

💡 참고 사항

Summary by CodeRabbit

  • 신규 기능

    • 로그인 상태에 따라 알림 자동 새로고침 및 활성화 여부가 동적으로 제어됩니다.
  • 버그 수정

    • 알림이 비활성화된 경우 불필요한 자동 새로고침이 발생하지 않도록 개선되었습니다.

@minimo-9 minimo-9 self-assigned this Aug 3, 2025
@minimo-9 minimo-9 added 🐞 bug 버그관련 📬 API 서버 api 통신관련 labels Aug 3, 2025
@minimo-9 minimo-9 linked an issue Aug 3, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Aug 3, 2025

Walkthrough

useNotifications 훅이 로그인 상태(isLoggedIn)를 두 번째 인자로 받아, 사용자의 로그인 여부에 따라 쿼리 활성화와 자동 refetch 주기를 동적으로 제어하도록 변경되었습니다. 이에 따라 Header 컴포넌트에서 훅 호출 방식이 수정되었습니다.

Changes

Cohort / File(s) Change Summary
Header 컴포넌트 내 훅 호출 수정
src/components/Header.tsx
useNotifications 훅 호출 시 두 번째 인자(isLoggedIn) 추가. 기존 { size: 10 }{ size: 10 }, isLoggedIn으로 변경.
useNotifications 훅 시그니처 및 동작 개선
src/hooks/useNotification.ts
훅 시그니처에 두 번째 인자(isEnabled?: boolean) 추가 및 기본값 true. 쿼리 활성화와 refetch 주기를 isEnabled에 따라 동적으로 제어.

Sequence Diagram(s)

sequenceDiagram
    participant Header
    participant useNotifications
    participant useQuery

    Header->>useNotifications: 호출({ size: 10 }, isLoggedIn)
    useNotifications->>useQuery: enabled: isLoggedIn, refetchInterval: isLoggedIn ? 10000 : false
    useQuery-->>useNotifications: 결과 반환
    useNotifications-->>Header: 알림 데이터 반환
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

🔨 Refactor

Suggested reviewers

  • BokyungCodes
  • LeeCh0129

Poem

🐇
로그인 여부 따라 알림이 달라져요,
훅의 인자 하나로 제어가 쉬워져요.
자동 새로고침도 똑똑하게,
코드는 더 깔끔하게!
토끼도 박수 짝짝짝—
리팩터링, 멋진 변화에 토끼가 춤춰요!
🥕

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c9f0a3 and 6b80475.

📒 Files selected for processing (2)
  • src/components/Header.tsx (1 hunks)
  • src/hooks/useNotification.ts (1 hunks)
🔇 Additional comments (3)
src/hooks/useNotification.ts (2)

46-49: 함수 시그니처 업데이트가 적절합니다.

isEnabled 매개변수 추가로 로그인 상태에 따른 쿼리 제어가 가능해졌습니다. 기본값 true로 설정하여 기존 호출 코드와의 호환성도 유지되었습니다.


56-57: 로그인 상태에 따른 쿼리 제어 로직이 올바릅니다.

isEnabledfalse일 때 쿼리 실행과 자동 refetch를 모두 비활성화하여 401 에러를 방지합니다. 이는 PR 목표인 "로그인하지 않은 상태에서 반복적인 알림 API 요청으로 인한 401 에러" 문제를 효과적으로 해결합니다.

src/components/Header.tsx (1)

24-24: 훅 사용법 업데이트가 정확합니다.

isLoggedIn 상태를 useNotifications 훅의 두 번째 인자로 전달하여, 로그인하지 않은 사용자의 경우 알림 API 호출을 방지합니다. 이는 PR의 핵심 목표인 401 에러 해결을 위한 올바른 구현입니다.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/131

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@BokyungCodes BokyungCodes left a comment

Choose a reason for hiding this comment

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

불필요한 API 호출 방지한거 조아요!

Copy link
Contributor

@LeeCh0129 LeeCh0129 left a comment

Choose a reason for hiding this comment

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

알람 API 고생하셨습니다!

@minimo-9 minimo-9 merged commit 75c3ed9 into develop Aug 4, 2025
2 checks passed
@minimo-9 minimo-9 deleted the fix/131 branch August 4, 2025 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📬 API 서버 api 통신관련 🐞 bug 버그관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] 알림 네트워크 오류 수정

4 participants