@@ -7,12 +7,14 @@ interface AuthState {
77 isLoggedIn : boolean ;
88 isCheckingAuth : boolean ;
99 hasFetchedAuth : boolean ;
10+ lastCheckedShareUri : string | null ;
1011 boardShare : GetBoardShareResponse [ "data" ] | null ;
1112 checkAuth : ( options ?: {
1213 force ?: boolean ;
1314 } ) => Promise < GetBoardShareResponse [ "data" ] | null > ;
1415 checkAuthForSharedBoard : (
15- shareUri : string
16+ shareUri : string ,
17+ options ?: { force ?: boolean }
1618 ) => Promise < CheckLoginResponse [ "data" ] | null > ;
1719 setLoggedIn : (
1820 value : boolean ,
@@ -25,6 +27,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
2527 isLoggedIn : false ,
2628 isCheckingAuth : false ,
2729 hasFetchedAuth : false ,
30+ lastCheckedShareUri : null ,
2831 boardShare : null ,
2932
3033 checkAuth : async ( { force = false } = { } ) => {
@@ -59,10 +62,11 @@ export const useAuthStore = create<AuthState>((set, get) => ({
5962 }
6063 } ,
6164
62- checkAuthForSharedBoard : async ( shareUri : string ) => {
63- const { hasFetchedAuth } = get ( ) ;
65+ checkAuthForSharedBoard : async ( shareUri : string , { force = false } = { } ) => {
66+ const { lastCheckedShareUri } = get ( ) ;
6467
65- if ( hasFetchedAuth ) {
68+ // 같은 shareUri로 이미 체크했으면 스킵 (force가 아닌 경우)
69+ if ( lastCheckedShareUri === shareUri && ! force ) {
6670 return null ;
6771 }
6872
@@ -75,6 +79,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
7579 isLoggedIn : response . data . validUser ,
7680 isCheckingAuth : false ,
7781 hasFetchedAuth : true ,
82+ lastCheckedShareUri : shareUri ,
7883 } ) ;
7984
8085 return response . data ;
@@ -83,6 +88,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
8388 isLoggedIn : false ,
8489 isCheckingAuth : false ,
8590 hasFetchedAuth : true ,
91+ lastCheckedShareUri : shareUri ,
8692 } ) ;
8793
8894 return null ;
@@ -103,6 +109,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
103109 isLoggedIn : false ,
104110 isCheckingAuth : false ,
105111 hasFetchedAuth : true ,
112+ lastCheckedShareUri : null ,
106113 boardShare : null ,
107114 } ) ;
108115 } ,
0 commit comments