11import {
2- cleanDataAtom ,
32 isFirstProfileViewAtom ,
43 lastEntranceAtom ,
54 userGenderAtom ,
@@ -15,12 +14,11 @@ import { usePurchasedProfiles, useSelfProfile } from "@/hooks/queries/profiles";
1514import { useViewerSelf } from "@/hooks/queries/viewers" ;
1615import { Gender } from "@/types/profile" ;
1716import { useQueryClient } from "@tanstack/react-query" ;
18- import { useAtom , useAtomValue , useSetAtom } from "jotai" ;
17+ import { useAtom , useAtomValue } from "jotai" ;
1918import { useCallback , useEffect , useState } from "react" ;
2019import { UserData } from "@/types/user" ;
2120import { useAuth } from "@/hooks/useAuth" ;
2221import { useUserInfo } from "@/hooks/queries/users" ;
23- import { DATA_EXPIRY } from "@/env" ;
2422
2523export const useUser = ( ) : UserData & {
2624 setIsFirstProfileView : ( value : boolean ) => void ;
@@ -43,15 +41,13 @@ export const useUser = (): UserData & {
4341 const [ isFirstProfileView , setIsFirstProfileView ] = useAtom (
4442 isFirstProfileViewAtom ,
4543 ) ;
44+ const lastEntranceTime = useAtomValue ( lastEntranceAtom ) ;
4645 const [ viewer , setViewer ] = useAtom ( viewerAtom ) ;
4746 const [ purchasedProfiles , setPurchasedProfiles ] = useAtom (
4847 purchasedProfilesAtom ,
4948 ) ;
50- const [ lastEntranceTime , setLastEntranceTime ] = useAtom ( lastEntranceAtom ) ;
5149 const savedProfiles = useAtomValue ( savedProfilesAtom ) ;
5250 const recentlyViewedProfileIds = useAtomValue ( recentlyViewedProfilesAtom ) ;
53- const clearDataAtom = useSetAtom ( cleanDataAtom ) ;
54-
5551 const queryClient = useQueryClient ( ) ;
5652
5753 const { data : profileRes , isPending : isProfilePending } = useSelfProfile ( {
@@ -72,19 +68,6 @@ export const useUser = (): UserData & {
7268 setRefreshInitiated ( true ) ;
7369 } , [ queryClient ] ) ;
7470
75- useEffect ( ( ) => {
76- if (
77- lastEntranceTime === null ||
78- lastEntranceTime < new Date ( DATA_EXPIRY ) . getTime ( )
79- ) {
80- clearDataAtom ( ) ;
81- } else {
82- setLastEntranceTime ( Date . now ( ) ) ;
83- }
84- // This hook runs only once on mount
85- // eslint-disable-next-line react-hooks/exhaustive-deps
86- } , [ ] ) ;
87-
8871 useEffect ( ( ) => {
8972 if ( isAuthenticated ) {
9073 refreshUser ( ) ;
0 commit comments