You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Parsed once on mount. An unparsable value seeds the same 12:00 PM placeholder an empty one gets, so it is not visually distinct from a deliberate noon.
132
+
// Parsed once on mount. An unparsable value seeds the same 12:00 PM placeholder an empty one gets.
Copy file name to clipboardExpand all lines: src/hooks/useNow.ts
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,9 @@ import {getSnapshot, subscribe} from '@libs/NowStore';
2
2
3
3
import{useSyncExternalStore}from'react';
4
4
5
-
/** SSR is unsupported. Server module-load time would diverge from the client's fresh `new Date()` at hydration; throwing surfaces the problem loudly. */
6
-
functiongetServerSnapshot(): Date{
7
-
thrownewError('[NowStore] useNow is not SSR-safe; server and client snapshots would diverge on hydration.');
8
-
}
9
-
5
+
/** No `getServerSnapshot`: React also calls it on the client during hydration, so a throwing one would not stay confined to SSR. */
Copy file name to clipboardExpand all lines: src/languages/__mocks__/IntlStore.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ class IntlStore {
50
50
51
51
privatestaticlisteners=newSet<()=>void>();
52
52
53
-
// One cached snapshot so repeated `useSyncExternalStore` reads return the same reference and never trigger an infinite render loop. Replaced (not mutated) on locale change so subscribers see a fresh identity.
53
+
// One cached snapshot, so repeated `useSyncExternalStore` reads return the same reference. Replaced, never mutated.
// Real behaviour: mutate currentLocale, replace the snapshot, notify subscribers. Otherwise tests exercising a locale switch see no effect and coverage silently fails-open.
65
+
// Real behaviour, otherwise a suite exercising a locale switch sees no effect and passes for the wrong reason.
Log.warn('[DateUtils] Intl.DateTimeFormat retry with backward timezone also failed',{locale, formatKey, timeZone, backwardTimeZone, retryError});
99
-
returnnull;
100
-
}
101
-
}
102
-
// Hermes implements DateTimeFormat, so the realistic failure is one bad locale tag. Retry on the default locale so dates degrade to English rather than blank.
// Capture the mapped tz once. Passing the unmapped tz into isToday/isYesterday/toZonedTime after formatting `date` with the mapped tz would let the "today" branch and the display disagree on the reference zone if a legacy alias with a divergent offset is ever added to `timezoneNewToBackwardMap`. The map's backward IANA values are valid tz identifiers that date-fns accepts, they just aren't in the tight `SelectedTimezone` union, so the cast is safe.
278
+
// Map once and reuse, so the isToday/isYesterday branches and the rendered string cannot resolve against different zones.
279
+
// The backward IANA values are real tz identifiers, just outside the tighter `SelectedTimezone` union.
// Fixed-year UTC mid-month dates. Month name is year-independent, so UTC + mid-month sidesteps any local-tz boundary that could shift a January-1 or December-31 endpoint into the neighbouring month on extreme timezones.
485
+
// Mid-month in UTC, so no timezone can shift a month-edge date into the neighbouring month.
// Extract the year from the wire string directly, so a "2023-12-31" transaction viewed on Dec 31 evening (Jan 1 UTC) still compares 2023 vs 2023 and does not spuriously suffix ", 2023" onto today's row. Falls back to UTC parsing when the input is not a leading-year string.
1192
+
// Read the year off the wire string, so a Dec 31 transaction viewed that evening (already Jan 1 in UTC) is not
1193
+
// suffixed with a year on what is still today's row.
// Requested locale not loaded yet. Fall back to the currently loaded locale so callers (OnyxDerived, etc.) get a real string instead of a raw dotted path they might persist into derived state.
116
+
// Requested locale not loaded yet. Fall back to the loaded one, so callers never persist a raw dotted path.
// Seeded at module load. Refreshed by `tick` and by `subscribe`. Never advanced from `getSnapshot` so the useSyncExternalStore purity contract holds (repeated reads in one render return the same reference).
11
+
// Advanced by `tick` and `subscribe`, never by `getSnapshot`, which must stay pure for `useSyncExternalStore`.
// Refresh (and notify existing siblings) BEFORE adding the new listener, so the fresh subscriber does not receive a redundant onStoreChange in addition to React's mount-time getSnapshot comparison.
47
+
// Refresh before adding the listener, so the new subscriber is not notified on top of React's own mount-time check.
0 commit comments