Skip to content

Commit

Permalink
fix: date comparison without timezone in consideration (#3832)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshanzel authored Nov 21, 2024
1 parent b368818 commit 9314871
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export function ReadingStreakButton({
const isMobile = useViewSize(ViewSize.MobileL);
const [shouldShowStreaks, setShouldShowStreaks] = useState(false);
const hasReadToday =
new Date(streak?.lastViewAt).getDate() === new Date().getDate();
streak?.lastViewAtTz &&
new Date(streak.lastViewAtTz).getDate() === new Date().getDate();

const handleToggle = useCallback(() => {
setShouldShowStreaks((state) => !state);
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/graphql/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export const USER_STREAK_FRAGMENT = gql`
total
current
lastViewAt
lastViewAtTz
weekStart
}
`;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/graphql/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ export interface UserStreak {
current: number;
weekStart: DayOfWeek;
lastViewAt: Date;
lastViewAtTz: Date;
}

export const getReadingStreak = async (): Promise<UserStreak> => {
Expand Down

0 comments on commit 9314871

Please sign in to comment.