Skip to content

Commit 64c29cc

Browse files
dylanjeffersclaudecursoragent
authored
Remove download tracking UI from track pages (#14074)
## Summary This PR removes download count tracking and display functionality from track pages, including the download stats button and dedicated download section component. ## Key Changes - **TrackStats.tsx**: Removed the download count display button that showed formatted download statistics - Removed `useTrackDownloadCount` hook and related download count fetching logic - Removed `IconCloudDownload` import and download message - Removed `is_downloadable` field from track data selection - **GiantTrackTile.tsx**: Removed the download section component from the track tile - Removed lazy-loaded `DownloadSection` component - Removed `useStems` hook and download availability logic - Removed conditional rendering of the download section - Removed `Suspense` and `lazy` imports that were only used for the download section - **useTrackMetadata.ts**: Updated downloads metadata display logic - Changed to only show download count when both `isDownloadable` is true AND `downloadCount > 0` - Prevents displaying empty download statistics ## Implementation Details The changes maintain the metadata structure but make the downloads field conditional on having actual download data, ensuring cleaner UI by not showing download information when there's nothing to display. https://claude.ai/code/session_01TFkhjQRGjeoZrtiaXsqC5j --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Dylan Jeffers <dylanjeffers@users.noreply.github.com>
1 parent b366981 commit 64c29cc

File tree

3 files changed

+7
-43
lines changed

3 files changed

+7
-43
lines changed

packages/common/src/hooks/useTrackMetadata.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ export const useTrackMetadata = ({
123123
{
124124
id: TrackMetadataType.DOWNLOADS,
125125
label: 'Downloads',
126-
value: isDownloadable ? formatCount(downloadCount) : '',
126+
value:
127+
isDownloadable && downloadCount > 0 ? formatCount(downloadCount) : '',
127128
isHidden: !isDownloadable
128129
}
129130
].filter(({ isHidden, value }) => !isHidden && !!value)

packages/web/src/components/track/GiantTrackTile.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Suspense, lazy, useCallback, useState, useEffect, useRef } from 'react'
1+
import { useCallback, useState, useEffect, useRef } from 'react'
22

33
import {
44
useTrackRank,
55
useRemixContest,
66
useToggleFavoriteTrack,
7-
useStems,
87
useTrack
98
} from '@audius/common/api'
109
import {
@@ -72,12 +71,6 @@ import { TrackDogEar } from './TrackDogEar'
7271
import { TrackMetadataList } from './TrackMetadataList'
7372
import { TrackStats } from './TrackStats'
7473

75-
const DownloadSection = lazy(() =>
76-
import('./DownloadSection').then((module) => ({
77-
default: module.DownloadSection
78-
}))
79-
)
80-
8174
const BUTTON_COLLAPSE_WIDTHS = {
8275
first: 1095,
8376
second: 1190,
@@ -219,8 +212,6 @@ export const GiantTrackTile = ({
219212
const { data: track } = useTrack(trackId, {
220213
select: (track) => pick(track, ['is_downloadable', 'preview_cid'])
221214
})
222-
const { data: stems = [] } = useStems(trackId)
223-
const hasDownloadableAssets = track?.is_downloadable || stems.length > 0
224215
// Preview button is shown for USDC-gated tracks if user does not have access
225216
// or is the owner
226217
const showPreview =
@@ -692,13 +683,6 @@ export const GiantTrackTile = ({
692683
) : null}
693684

694685
{renderTags()}
695-
{hasDownloadableAssets ? (
696-
<Box w='100%'>
697-
<Suspense>
698-
<DownloadSection trackId={trackId} />
699-
</Suspense>
700-
</Box>
701-
) : null}
702686
</Flex>
703687
</Paper>
704688
)

packages/web/src/components/track/TrackStats.tsx

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
import {
2-
useCurrentUserId,
3-
useTrack,
4-
useTrackDownloadCount
5-
} from '@audius/common/api'
1+
import { useCurrentUserId, useTrack } from '@audius/common/api'
62
import { ID, Name } from '@audius/common/models'
73
import { formatCount, isLongFormContent, pluralize } from '@audius/common/utils'
84
import {
95
Flex,
10-
IconCloudDownload,
116
IconHeart,
127
IconMessage,
138
IconPlay,
149
IconRepost,
1510
PlainButton
1611
} from '@audius/harmony'
17-
import { encodeHashId } from '@audius/sdk'
1812
import { pick } from 'lodash'
1913
import { useDispatch } from 'react-redux'
2014

@@ -29,8 +23,7 @@ const messages = {
2923
repost: 'Repost',
3024
favorite: 'Favorite',
3125
comment: 'Comment',
32-
play: 'Play',
33-
download: 'Download'
26+
play: 'Play'
3427
}
3528

3629
type TrackStatsProps = {
@@ -51,13 +44,10 @@ export const TrackStats = (props: TrackStatsProps) => {
5144
'is_unlisted',
5245
'play_count',
5346
'comments_disabled',
54-
'genre',
55-
'is_downloadable'
47+
'genre'
5648
])
5749
})
5850
const { data: currentUserId } = useCurrentUserId()
59-
const trackIdHash = partialTrack ? encodeHashId(trackId as number) : null
60-
const { data: downloadCount = 0 } = useTrackDownloadCount(trackIdHash)
6151
const dispatch = useDispatch()
6252
const comment_count = partialTrack?.comment_count ?? 0
6353

@@ -70,8 +60,7 @@ export const TrackStats = (props: TrackStatsProps) => {
7060
play_count,
7161
is_stream_gated,
7262
owner_id,
73-
is_unlisted,
74-
is_downloadable
63+
is_unlisted
7564
} = partialTrack
7665

7766
const isOwner = currentUserId === owner_id
@@ -151,16 +140,6 @@ export const TrackStats = (props: TrackStatsProps) => {
151140
{formatCount(play_count)} {pluralize(messages.play, play_count)}
152141
</PlainButton>
153142
) : null}
154-
{is_downloadable ? (
155-
<PlainButton
156-
iconLeft={IconCloudDownload}
157-
size='large'
158-
variant='subdued'
159-
>
160-
{formatCount(downloadCount)}{' '}
161-
{pluralize(messages.download, downloadCount)}
162-
</PlainButton>
163-
) : null}
164143
</Flex>
165144
)
166145
}

0 commit comments

Comments
 (0)