Skip to content

Commit

Permalink
fix: streak usage of last view at to timezone considered (#3873)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshanzel authored Nov 25, 2024
1 parent d369ee5 commit f9093f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/shared/src/hooks/post/useViewPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const useViewPost = (): UseMutateAsyncFunction<
mutationFn: sendViewPost,
onSuccess: async () => {
const streak = client.getQueryData<UserStreak>(streakKey);
const isNewStreak = !streak?.lastViewAt;
const isNewStreak = !streak?.lastViewAtTz;
const isFirstViewToday =
getDay(new Date(streak?.lastViewAt)) !== getDay(new Date());
getDay(new Date(streak?.lastViewAtTz)) !== getDay(new Date());

if (isNewStreak || isFirstViewToday) {
await client.refetchQueries({ queryKey: streakKey });
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/hooks/streaks/useReadingStreak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const useReadingStreak = (): UserReadingStreak => {

const [clearQueries] = useDebounceFn(async () => {
const hasReadToday =
streak?.lastViewAt &&
getDay(new Date(streak?.lastViewAt)) === getDay(new Date());
streak?.lastViewAtTz &&
getDay(new Date(streak?.lastViewAtTz)) === getDay(new Date());

if (!hasReadToday) {
await queryClient.invalidateQueries({
Expand Down

0 comments on commit f9093f8

Please sign in to comment.