Skip to content

Commit 8d650bb

Browse files
committed
fix: rename shouldCountStreak to shouldIcrementStreak and update date comparison logic
1 parent cdc2a18 commit 8d650bb

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/components/Layout/AppLayout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import { AuthProvider } from 'src/providers/AuthProvider'
1111
import { Header } from './Header'
1212

1313
export const AppLayout = () => {
14-
const { isAuthModalOpen, setStreak, shouldCountStreak } = useAuth()
14+
const { isAuthModalOpen, setStreak, shouldIcrementStreak } = useAuth()
1515
const postStreakMutation = usePostStreak()
1616

1717
useEffect(() => {
18-
if (shouldCountStreak()) {
18+
if (shouldIcrementStreak()) {
1919
postStreakMutation.mutateAsync(undefined).then((data) => {
2020
setStreak(data.streak)
2121
identifyUserStreak(data.streak)
2222
})
2323
}
24-
}, [shouldCountStreak])
24+
}, [])
2525

2626
return (
2727
<AuthProvider>

src/features/auth/hooks/useAuth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export const useAuth = () => {
1010

1111
const isConnected = authStore.user != null
1212

13-
const shouldCountStreak = useCallback(() => {
13+
const shouldIcrementStreak = useCallback(() => {
1414
if (!isConnected) return false
1515

1616
const last = authStore.lastStreakUpdate
1717
if (!last) return true
1818

19-
const today = new Date().toDateString()
20-
const lastDay = new Date(last).toDateString()
19+
const today = new Date().toISOString()
20+
const lastDay = new Date(last).toISOString()
2121

2222
return today !== lastDay
2323
}, [isConnected, authStore.lastStreakUpdate])
@@ -33,7 +33,7 @@ export const useAuth = () => {
3333
...authModalStore,
3434
...authStore,
3535
isConnected,
36-
shouldCountStreak,
36+
shouldIcrementStreak,
3737
logout,
3838
}
3939
}

0 commit comments

Comments
 (0)