Skip to content

Commit 0969af4

Browse files
authored
Fix comment history (#13822)
<!-- CURSOR_SUMMARY --> > [!NOTE] > **Medium Risk** > Touches shared time utilities and SDK adapters, so subtle formatting/timezone behavior could change across the app; scope is small and largely import-level, but widely used. > > **Overview** > Standardizes date/time handling by switching multiple modules from direct `dayjs` imports to the shared configured `~/utils/dayjs` (and `@audius/common/utils` in web), ensuring required plugins (UTC/timezone/duration/advancedFormat) are consistently available. > > Removes ad-hoc `advancedFormat` plugin extension from `timeUtil.ts` and relies on the centralized `dayjs` setup; updates comment history to use the common `dayjs` and parse `createdAt` via `dayjs.utc(...)` for timestamps. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7659201. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 459889b commit 0969af4

5 files changed

Lines changed: 5 additions & 8 deletions

File tree

packages/common/src/adapters/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
type UpdateAlbumRequestBody,
1515
type UpdatePlaylistRequestBody
1616
} from '@audius/sdk'
17-
import dayjs from 'dayjs'
17+
import dayjs from '~/utils/dayjs'
1818
import { omit } from 'lodash'
1919
import snakecaseKeys from 'snakecase-keys'
2020

packages/common/src/adapters/notification.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
instanceOfPlaylistMilestoneNotificationActionData,
1111
instanceOfTrackMilestoneNotificationActionData
1212
} from '@audius/sdk'
13-
import dayjs from 'dayjs'
13+
import dayjs from '~/utils/dayjs'
1414

1515
import { BadgeTier, type ID } from '~/models'
1616
import type { ChallengeRewardID } from '~/models/AudioRewards'

packages/common/src/adapters/track.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
OptionalId
1515
} from '@audius/sdk'
1616
import camelcaseKeys from 'camelcase-keys'
17-
import dayjs from 'dayjs'
17+
import dayjs from '~/utils/dayjs'
1818
import { omit, pick, mapValues } from 'lodash'
1919
import snakecaseKeys from 'snakecase-keys'
2020

packages/common/src/utils/timeUtil.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import dayjs from 'dayjs'
2-
import advancedFormat from 'dayjs/plugin/advancedFormat'
1+
import dayjs from './dayjs'
32

43
export const MS_IN_S = 1000
54
export const S_IN_MIN = 60
@@ -35,8 +34,6 @@ export const getLargestTimeUnitText = (time: Date) => {
3534
return unit ? `${Math.floor(diff / timeUnitMsMap[unit])}${unit}` : 'just now'
3635
}
3736

38-
dayjs.extend(advancedFormat)
39-
4037
export const formatDateWithTimezoneOffset = (date: string): string => {
4138
return dayjs.utc(date).local().format('M/D/YY')
4239
}

packages/web/src/pages/comment-history/components/desktop/CommentHistoryPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@audius/common/api'
99
import { Name } from '@audius/common/models'
1010
import { profilePage } from '@audius/common/src/utils/route'
11+
import { dayjs } from '@audius/common/utils'
1112
import {
1213
Box,
1314
Button,
@@ -20,7 +21,6 @@ import {
2021
Text,
2122
TextLink
2223
} from '@audius/harmony'
23-
import dayjs from 'dayjs'
2424
import InfiniteScroll from 'react-infinite-scroller'
2525
import { useNavigate } from 'react-router'
2626

0 commit comments

Comments
 (0)