-
Notifications
You must be signed in to change notification settings - Fork 1
225 버그 몇 가지 수정하기 #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
The head ref may contain hidden characters: "225-\uBC84\uADF8-\uBA87-\uAC00\uC9C0-\uC218\uC815\uD558\uAE30"
225 버그 몇 가지 수정하기 #227
Conversation
WalkthroughThis update introduces several refactorings and enhancements across the codebase. Key changes include optimistically updating the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TodoList
participant MainTodo
User->>TodoList: Clicks Close Button
TodoList->>MainTodo: Calls handleClose()
MainTodo->>MainTodo: Updates card state via changeCard()
sequenceDiagram
participant User
participant useExtremeMode
participant QueryClient
participant settingsApi
User->>useExtremeMode: Toggle Extreme Mode
useExtremeMode->>QueryClient: Optimistically update extremeMode in cache
useExtremeMode->>settingsApi: Send mutation
alt Mutation fails
useExtremeMode->>QueryClient: Rollback to previous cache
else Mutation succeeds
useExtremeMode->>QueryClient: Invalidate settings query
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn config production Use Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/components/MainTodo/index.tsx (1)
78-89
:⚠️ Potential issueUpdate dependency array for handleClickSideButton.
The
handleClickSideButton
callback referenceschangeCard
on line 85 but doesn't include it in the dependency array. This could lead to stale closure issues.const handleClickSideButton = useCallback( (type: ModalType) => { if (!isLogin) { if (window.confirm('로그인을 하시겠습니까?')) { return usersApi.login(); } } else { changeCard(currentCard, type); } }, - [isLogin], + [isLogin, currentCard, changeCard], );
🧹 Nitpick comments (1)
src/hooks/useExtremeMode.tsx (1)
84-91
: Consider adding type safety for the context parameter.The error handler correctly uses the context for rollback, but the context parameter lacks type safety which could lead to runtime errors.
Apply this diff to improve type safety:
- onError(error: AxiosError, _, context) { + onError(error: AxiosError, _, context: any) {Or better yet, define a proper type for the context:
+interface MutationContext { + data: { + extremeMode: boolean; + [key: string]: any; + }; + [key: string]: any; +} - onError(error: AxiosError, _, context) { + onError(error: AxiosError, _, context: MutationContext) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
src/__test__/hooks/useExtremeMode.test.tsx
(1 hunks)src/components/AddTodo.tsx
(1 hunks)src/components/MainTodo/index.tsx
(2 hunks)src/components/TodoCard/index.tsx
(1 hunks)src/components/TodoList/index.tsx
(5 hunks)src/hooks/LoginContext.tsx
(2 hunks)src/hooks/useExtremeMode.tsx
(1 hunks)src/shared/apis.ts
(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/shared/apis.ts (1)
src/App.tsx (1)
queryClient
(19-21)
src/__test__/hooks/useExtremeMode.test.tsx (1)
src/shared/apis.ts (1)
settingsApi
(193-201)
src/hooks/useExtremeMode.tsx (1)
src/App.tsx (1)
queryClient
(19-21)
🔇 Additional comments (14)
src/hooks/useExtremeMode.tsx (1)
63-76
: Excellent optimistic update implementation!The optimistic update pattern is correctly implemented following React Query best practices. The logic properly cancels ongoing queries, backs up previous data, and updates the cache optimistically.
src/hooks/LoginContext.tsx (2)
1-7
: Good timing improvement for login state initialization.Changing from
useEffect
touseLayoutEffect
ensures the login state is determined before the browser paints, preventing potential layout shifts during initial render.
46-48
: LGTM - Synchronous login check prevents render flicker.Since
checkLogin
only reads from localStorage (which is synchronous), usinguseLayoutEffect
is appropriate and won't cause performance issues while ensuring login state is available before the first paint.src/components/AddTodo.tsx (1)
118-120
: Nice code simplification with short-circuit evaluation.The refactor from an explicit
if
block to a short-circuit logical AND expression is more concise while maintaining the same functionality. ThesetCategoryError(undefined)
will only be called whencategoryError !== undefined
is true.src/shared/apis.ts (3)
1-1
: Good cleanup removing unused import.Removing the unused
Cancel
import keeps the codebase clean.
33-41
: Excellent async query cancellation in request interceptor.Making the request interceptor async and awaiting
queryClient.cancelQueries()
ensures that query cancellations complete before proceeding. This prevents race conditions and aligns with the optimistic update patterns implemented elsewhere in the codebase.
62-75
: Proper async handling in response interceptor error handling.The async error handler with awaited query cancellation ensures proper cleanup when handling 401 errors. This consistent pattern across interceptors improves the reliability of query state management.
src/__test__/hooks/useExtremeMode.test.tsx (1)
152-162
: Excellent test reliability improvement!The refactoring separates concerns by explicitly waiting for the pomodoro state initialization before firing the event, then waiting for the API call. This makes the test more deterministic and less prone to race conditions.
src/components/TodoCard/index.tsx (1)
322-324
: Clean conditional logic simplification!The refactored code uses short-circuit evaluation to handle both empty input validation and error state clearing in a single, more readable expression. This maintains the same functionality while reducing complexity.
src/components/MainTodo/index.tsx (1)
91-102
: Excellent refactoring for better separation of concerns!The extraction of
changeCard
logic into a reusable memoized function improves code organization and maintainability. The proper dependency arrays ensure optimal re-rendering behavior.src/components/TodoList/index.tsx (4)
5-5
: Good addition of IconAtom import and handleClose prop.The import and interface update properly support the new close button functionality.
Also applies to: 72-72
158-162
: Excellent UI enhancement with consistent header layout.The addition of the close button with proper accessibility attributes (ariaLabel, tabIndex) and the consistent header structure for both TODO sections improves the user experience. The flex layout for
.header__todo
provides appropriate space-between alignment.Also applies to: 189-201
156-156
: Verify padding reduction impact on layout.The padding was reduced from "2rem 1.5rem" to "1rem 1.5rem". Ensure this change doesn't negatively impact the visual spacing or component layout across different screen sizes.
314-318
: Clean CSS implementation for header layout.The
.header__todo
styles provide proper flex layout for the header sections with space-between alignment and fixed height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
의견 없습니당 고생하셨습니다~
const accessToken = localStorage.getItem(EXTREME_TOKEN_STORAGE); | ||
const email = localStorage.getItem(EXTREME_EMAIL_STORAGE); | ||
if ( | ||
config.url !== '/api/users/callback/google/start' && | ||
!email && | ||
!accessToken | ||
) { | ||
queryClient.cancelQueries(); | ||
await queryClient.cancelQueries(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await 가 없을 때 뭔가 에러가 있었나요?
가랏, 코드래빗~ 🐰
Summary by CodeRabbit
New Features
Improvements
Bug Fixes