Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/common/src/hooks/useTrackMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export const useTrackMetadata = ({
{
id: TrackMetadataType.DOWNLOADS,
label: 'Downloads',
value: isDownloadable ? formatCount(downloadCount) : '',
value:
isDownloadable && downloadCount > 0 ? formatCount(downloadCount) : '',
isHidden: !isDownloadable
}
].filter(({ isHidden, value }) => !isHidden && !!value)
Expand Down
18 changes: 1 addition & 17 deletions packages/web/src/components/track/GiantTrackTile.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Suspense, lazy, useCallback, useState, useEffect, useRef } from 'react'
import { useCallback, useState, useEffect, useRef } from 'react'

import {
useTrackRank,
useRemixContest,
useToggleFavoriteTrack,
useStems,
useTrack
} from '@audius/common/api'
import {
Expand Down Expand Up @@ -72,12 +71,6 @@ import { TrackDogEar } from './TrackDogEar'
import { TrackMetadataList } from './TrackMetadataList'
import { TrackStats } from './TrackStats'

const DownloadSection = lazy(() =>
import('./DownloadSection').then((module) => ({
default: module.DownloadSection
}))
)

const BUTTON_COLLAPSE_WIDTHS = {
first: 1095,
second: 1190,
Expand Down Expand Up @@ -219,8 +212,6 @@ export const GiantTrackTile = ({
const { data: track } = useTrack(trackId, {
select: (track) => pick(track, ['is_downloadable', 'preview_cid'])
})
const { data: stems = [] } = useStems(trackId)
const hasDownloadableAssets = track?.is_downloadable || stems.length > 0
// Preview button is shown for USDC-gated tracks if user does not have access
// or is the owner
const showPreview =
Expand Down Expand Up @@ -692,13 +683,6 @@ export const GiantTrackTile = ({
) : null}

{renderTags()}
{hasDownloadableAssets ? (
<Box w='100%'>
<Suspense>
<DownloadSection trackId={trackId} />
</Suspense>
</Box>
) : null}
</Flex>
</Paper>
)
Expand Down
29 changes: 4 additions & 25 deletions packages/web/src/components/track/TrackStats.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import {
useCurrentUserId,
useTrack,
useTrackDownloadCount
} from '@audius/common/api'
import { useCurrentUserId, useTrack } from '@audius/common/api'
import { ID, Name } from '@audius/common/models'
import { formatCount, isLongFormContent, pluralize } from '@audius/common/utils'
import {
Flex,
IconCloudDownload,
IconHeart,
IconMessage,
IconPlay,
IconRepost,
PlainButton
} from '@audius/harmony'
import { encodeHashId } from '@audius/sdk'
import { pick } from 'lodash'
import { useDispatch } from 'react-redux'

Expand All @@ -29,8 +23,7 @@ const messages = {
repost: 'Repost',
favorite: 'Favorite',
comment: 'Comment',
play: 'Play',
download: 'Download'
play: 'Play'
}

type TrackStatsProps = {
Expand All @@ -51,13 +44,10 @@ export const TrackStats = (props: TrackStatsProps) => {
'is_unlisted',
'play_count',
'comments_disabled',
'genre',
'is_downloadable'
'genre'
])
})
const { data: currentUserId } = useCurrentUserId()
const trackIdHash = partialTrack ? encodeHashId(trackId as number) : null
const { data: downloadCount = 0 } = useTrackDownloadCount(trackIdHash)
const dispatch = useDispatch()
const comment_count = partialTrack?.comment_count ?? 0

Expand All @@ -70,8 +60,7 @@ export const TrackStats = (props: TrackStatsProps) => {
play_count,
is_stream_gated,
owner_id,
is_unlisted,
is_downloadable
is_unlisted
} = partialTrack

const isOwner = currentUserId === owner_id
Expand Down Expand Up @@ -151,16 +140,6 @@ export const TrackStats = (props: TrackStatsProps) => {
{formatCount(play_count)} {pluralize(messages.play, play_count)}
</PlainButton>
) : null}
{is_downloadable ? (
<PlainButton
iconLeft={IconCloudDownload}
size='large'
variant='subdued'
>
{formatCount(downloadCount)}{' '}
{pluralize(messages.download, downloadCount)}
</PlainButton>
) : null}
</Flex>
)
}
Loading