-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] 가입된 동아리가 한개일때 바로 홈으로 이동되도록 수정 #94
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
The head ref may contain hidden characters: "fix/\uAC00\uC785\uB41C-\uB3D9\uC544\uB9AC-\uD558\uB098\uC77C\uB54C-\uC624\uB958\uC218\uC815"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| 'use client'; | ||
|
|
||
| import { useLayoutEffect, useRef } from 'react'; | ||
| import { useLayoutEffect } from 'react'; | ||
|
|
||
| import { useClubStore } from '@/stores/useClubStore'; | ||
| import { useUserStore } from '@/stores/useUserStore'; | ||
|
|
@@ -14,13 +14,20 @@ interface UserHydratorProps { | |
| } | ||
|
|
||
| function UserHydrator({ userInfo, clubInfo, children }: UserHydratorProps) { | ||
| const hydrated = useRef(false); | ||
|
|
||
| useLayoutEffect(() => { | ||
| if (hydrated.current) return; | ||
| useUserStore.setState(userInfo, false, 'setUser'); | ||
| useClubStore.setState(clubInfo, false, 'setClub'); | ||
| hydrated.current = true; | ||
| const currentUser = useUserStore.getState(); | ||
| const currentClub = useClubStore.getState(); | ||
|
|
||
| if ( | ||
| currentUser.id !== userInfo.id || | ||
| currentUser.profileImageUrl !== userInfo.profileImageUrl | ||
| ) { | ||
| useUserStore.setState(userInfo, false, 'setUser'); | ||
| } | ||
|
|
||
| if (currentClub.clubId !== clubInfo.clubId || currentClub.clubName !== clubInfo.clubName) { | ||
| useClubStore.setState(clubInfo, false, 'setClub'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check ClubIdentifier type definition
rg -n "type ClubIdentifier|interface ClubIdentifier" --type=ts -A10Repository: Team-Weeth/weeth-client Length of output: 225 🏁 Script executed: #!/bin/bash
# View the code context around line 29 in user-hydrator.tsx
cat -n src/providers/user-hydrator.tsx | sed -n '20,40p'Repository: Team-Weeth/weeth-client Length of output: 630 🏁 Script executed: #!/bin/bash
# Find the club store definition and setClub action
rg -n "setClub|export.*createStore" --type=ts -B2 -A8 | head -50Repository: Team-Weeth/weeth-client Length of output: 2883 🏁 Script executed: #!/bin/bash
# Check what type clubInfo has in user-hydrator.tsx
rg -n "clubInfo" src/providers/user-hydrator.tsx -B3 -A3Repository: Team-Weeth/weeth-client Length of output: 686
ClubIdentifier에 🤖 Prompt for AI Agents |
||
| } | ||
| }, [clubInfo, userInfo]); | ||
|
|
||
| return children; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ export const useClubStore = create( | |
| combine(initialState, (set) => ({ | ||
| setClubId: (clubId: string) => | ||
| set({ clubId, clubName: null, clubProfileImageUrl: null }, false, 'setClubId'), | ||
| syncClubId: (clubId: string) => set({ clubId }, false, 'syncClubId'), | ||
| setClub: (clubId: string, clubName: string, clubProfileImageUrl?: string | null) => | ||
| set( | ||
| { clubId, clubName, clubProfileImageUrl: clubProfileImageUrl ?? null }, | ||
|
|
@@ -24,7 +25,24 @@ export const useClubStore = create( | |
| ), | ||
| reset: () => set(initialState, false, 'reset'), | ||
| })), | ||
| { name: 'clubId' }, | ||
| { | ||
| name: 'clubId', | ||
| partialize: (state) => ({ | ||
| ...(state.clubId ? { clubId: state.clubId } : {}), | ||
| ...(state.clubName ? { clubName: state.clubName } : {}), | ||
| ...(state.clubProfileImageUrl ? { clubProfileImageUrl: state.clubProfileImageUrl } : {}), | ||
| }), | ||
| merge: (persistedState, currentState) => { | ||
| const persisted = (persistedState ?? {}) as Partial<ClubState>; | ||
|
|
||
| return { | ||
| ...currentState, | ||
| clubId: persisted.clubId ?? currentState.clubId, | ||
| clubName: persisted.clubName ?? currentState.clubName, | ||
| clubProfileImageUrl: persisted.clubProfileImageUrl ?? currentState.clubProfileImageUrl, | ||
| }; | ||
|
Comment on lines
+35
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
의도적인 null 할당을 존중하려면 🔧 currentState 우선 방식으로 변경 제안 merge: (persistedState, currentState) => {
const persisted = (persistedState ?? {}) as Partial<ClubState>;
return {
...currentState,
- clubId: persisted.clubId ?? currentState.clubId,
- clubName: persisted.clubName ?? currentState.clubName,
- clubProfileImageUrl:
- persisted.clubProfileImageUrl ?? currentState.clubProfileImageUrl,
+ clubId: currentState.clubId ?? persisted.clubId,
+ clubName: currentState.clubName ?? persisted.clubName,
+ clubProfileImageUrl:
+ currentState.clubProfileImageUrl ?? persisted.clubProfileImageUrl,
};
},🤖 Prompt for AI Agents |
||
| }, | ||
| }, | ||
| ), | ||
| { name: 'ClubStore' }, | ||
| ), | ||
|
|
@@ -37,6 +55,7 @@ export const useClubActions = () => | |
| useClubStore( | ||
| useShallow((store) => ({ | ||
| setClubId: store.setClubId, | ||
| syncClubId: store.syncClubId, | ||
| setClub: store.setClub, | ||
| reset: store.reset, | ||
| })), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.