Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: date comparison without timezone in consideration #3832

Merged
merged 8 commits into from
Nov 21, 2024
Merged

Conversation

sshanzel
Copy link
Member

@sshanzel sshanzel commented Nov 18, 2024

Changes

  • Even after reading new posts, the icon from the reading streak does not update to be filled.
  • The value of lastViewAt is in UTC when fetched from the API, which does not match the local time. With the update, we will utilize the user's set timezone. We can also use the current local timezone but it won't match other stats since behind the scenes all we use is the set timezone from the profile.

Events

Did you introduce any new tracking events?

Experiment

Did you introduce any new experiments?

Manual Testing

Caution

Please make sure existing components are not breaking/affected by this PR

Preview domain

https://mi-620.preview.app.daily.dev

Copy link

vercel bot commented Nov 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
daily-webapp ✅ Ready (Inspect) Visit Preview Nov 21, 2024 7:57am
1 Skipped Deployment
Name Status Preview Updated (UTC)
storybook ⬜️ Ignored (Inspect) Nov 21, 2024 7:57am

Copy link
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a question why can't we handle this in API returning the value we expect?

const isLaptop = useViewSize(ViewSize.Laptop);
const isMobile = useViewSize(ViewSize.MobileL);
const [shouldShowStreaks, setShouldShowStreaks] = useState(false);
const hasReadToday =
new Date(streak?.lastViewAt).getDate() === new Date().getDate();
const hasReadToday = getHasReadToday(streak?.lastViewAt, user?.timezone);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But shouldn't API just return it in the correct format already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, what is returned is the stored value, which is UTC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can maybe add a prop where the returned value involves the right tz.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced an API change for the timezome-adjusted value: dailydotdev/daily-api#2471

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then we don't need this one?

Copy link
Member Author

@sshanzel sshanzel Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility, I have kept the original column, and introduced a new one with timezone considered. So we'd still need this PR 🙏

@sshanzel sshanzel merged commit 9314871 into main Nov 21, 2024
10 checks passed
@sshanzel sshanzel deleted the MI-620 branch November 21, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants