fix(web): preserve timezone from URL query param on reload (#1411)#1444
fix(web): preserve timezone from URL query param on reload (#1411)#1444krapcys1-maker wants to merge 1 commit intobaires:masterfrom
Conversation
|
@krapcys1-maker is attempting to deploy a commit to the Alexis' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Tests and coverage both pass. The failure happens only at the final publish step of |
| const queryTimezone = router.query.tz | ||
| const timezoneFromQuery = Array.isArray(queryTimezone) ? queryTimezone[0] : queryTimezone | ||
| if (timezoneFromQuery && Time.zoneExists(timezoneFromQuery)) { | ||
| setTimezone(timezoneFromQuery) | ||
| setNow(new Time(timezoneFromQuery)) | ||
| } | ||
|
|
||
| const savedTheme = localStorage.getItem('theme') as ThemeType | null |
There was a problem hiding this comment.
This added 2 mixed concerns in one effect, now we handle the theme + tz sync
There was a problem hiding this comment.
Also I think there will be a double render on load now
|
Thanks for the review! Addressed all comments: 1. This added 2 mixed concerns in one effect, now we handle the theme + tz sync 2. Also I think there will be a double render on load now Summary: Addressed both review comments by separating concerns and avoiding the extra initial render. Theme logic remains in its own effect, timezone is initialized directly from the router query, and time updates still work for both date query changes and manual timezone changes. Validated with the existing Jest test command. All 1 validation command(s) passed. |
Fixes #1411
Summary
Fixes timezone reset to UTC on reload by honoring the existing tz query parameter in the page initialization flow.
Problem
When the page is reloaded with ?tz=, the UI timezone state was reinitialized to default UTC instead of the URL parameter.
What changed
Solution
The page now synchronizes timezone state with router query on mount/update, preserving expected timezone context across reload/open-in-new-tab scenarios.
Why
This aligns web behavior with the existing API/query behavior and avoids user-visible timezone drift.
Tests
npm test -- --runInBand tests/time.test.ts tests/days.test.ts