File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { UserType } from '@server/constants/user';
22import type { PermissionCheckOptions } from '@server/lib/permissions' ;
33import { hasPermission , Permission } from '@server/lib/permissions' ;
44import type { NotificationAgentKey } from '@server/lib/settings' ;
5+ import { useRouter } from 'next/router' ;
56import type { MutatorCallback } from 'swr' ;
67import useSWR from 'swr' ;
78
@@ -56,13 +57,19 @@ export const useUser = ({
5657 id,
5758 initialData,
5859} : { id ?: number ; initialData ?: User } = { } ) : UserHookResponse => {
60+ const router = useRouter ( ) ;
61+ const isAuthPage = / ^ \/ ( l o g i n | s e t u p | r e s e t p a s s w o r d ) / . test ( router . pathname ) ;
62+
5963 const {
6064 data,
6165 error,
6266 mutate : revalidate ,
6367 } = useSWR < User > ( id ? `/api/v1/user/${ id } ` : `/api/v1/auth/me` , {
6468 fallbackData : initialData ,
6569 refreshInterval : 30000 ,
70+ revalidateOnFocus : ! isAuthPage ,
71+ revalidateOnMount : ! isAuthPage ,
72+ revalidateOnReconnect : ! isAuthPage ,
6673 errorRetryInterval : 30000 ,
6774 shouldRetryOnError : false ,
6875 } ) ;
You can’t perform that action at this time.
0 commit comments