Repository navigation
feat(kno-15732): Skip quarters in feed timestamp formatting - #1077
Conversation
- Modify formatTimestamp to use 'month' unit for dates 3-12 months old instead of letting date-fns choose 'quarter', which reads oddly (e.g. '2 quarters ago') - Add optional formatTimestamp prop to NotificationCell and NotificationFeed to allow custom timestamp formatting without rebuilding the cell - Export FormatTimestampOptions and TimestampFormatter types for consumers - Add comprehensive tests for the new quarter-skipping behavior Fixes KNO-15732 Co-authored-by: Matt Kufchak <cellomatt@users.noreply.github.com>
🦋 Changeset detectedLatest commit: f8a7ba0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Matt Kufchak <cellomatt@users.noreply.github.com>
Co-authored-by: Matt Kufchak <cellomatt@users.noreply.github.com>
Bundle ReportChanges will increase total bundle size by 481 bytes (0.08%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @knocklabs/react-core-react-core-esmAssets Changed:
Files in
view changes for bundle: @knocklabs/react-react-esmAssets Changed:
Files in
Files in
view changes for bundle: @knocklabs/react-react-cjsAssets Changed:
Files in
Files in
view changes for bundle: @knocklabs/react-core-react-core-cjsAssets Changed:
Files in
|
…te-fns quarter range Co-authored-by: Matt Kufchak <cellomatt@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1077 +/- ##
==========================================
+ Coverage 75.38% 75.41% +0.03%
==========================================
Files 139 139
Lines 4371 4377 +6
Branches 1283 1287 +4
==========================================
+ Hits 3295 3301 +6
Misses 976 976
Partials 100 100
|
Description
This PR addresses the issue where the default
NotificationCelldisplays feed item timestamps between ~3 months and 1 year old as "last quarter", "2 quarters ago", or "3 quarters ago", which reads oddly to end users.What changed:
Modified
formatTimestampin@knocklabs/react-coreto passunit: "month"tointlFormatDistancewhenever the elapsed time falls in the range where date-fns would pick "quarter" (secondsInQuarter≤ elapsed <secondsInYear, using date-fns's own constants). This makes timestamps read "6 months ago" instead of "2 quarters ago". Because the cutoff matches date-fns exactly, there's no boundary window where a quarter result can slip through (e.g. now = Oct 31 11:00, timestamp = Jul 31 12:00 is under 3 calendar months but past date-fns's ~91.3-day threshold).Added optional
formatTimestampprop toNotificationCellandNotificationFeedcomponents, allowing customers to provide their own timestamp formatter without needing to rebuild the entire cell usingrenderItem.Exported new types (
FormatTimestampOptionsandTimestampFormatter) from both@knocklabs/react-coreand@knocklabs/reactfor TypeScript consumers.Why:
.rnf-notification-cell__timestampand render a custom timestamp viarenderItemdifferenceInCalendarQuarters(...) < 4check doesn't useMath.abs); these now show months tooExample outputs:
Checklist
Linear Issue: KNO-15732