Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[C-2792] Surface play count for hidden tracks #4022

Merged
merged 2 commits into from
Sep 6, 2023
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
4 changes: 2 additions & 2 deletions packages/mobile/src/components/lineup-tile/TrackTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ export const TrackTileComponent = ({
}
}, [track_id, dispatch, has_current_user_reposted])

const hideShare = field_visibility?.share === false
const hidePlays = field_visibility?.play_count === false
const hideShare = !isOwner && field_visibility?.share === false
const hidePlays = !isOwner && field_visibility?.play_count === false

return (
<LineupTile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export const TrackScreenDetailsTile = ({
hideShare={(is_unlisted && !isOwner) || !field_visibility?.share}
hideOverflow={!isReachable}
hideFavoriteCount={is_unlisted}
hideListenCount={is_unlisted && !field_visibility?.play_count}
hideListenCount={!isOwner && is_unlisted && !field_visibility?.play_count}
hideRepostCount={is_unlisted}
isPlaying={isPlaying && isPlayingId}
isPreviewing={isPreviewing}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/track/desktop/TrackTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const renderLockedOrPlaysContent = ({
}

const hidePlays = fieldVisibility
? fieldVisibility.play_count === false
? !isOwner && fieldVisibility.play_count === false
: false

return (
Expand Down
3 changes: 3 additions & 0 deletions packages/web/src/components/tracks-table/TracksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ export const TracksTable = ({

const renderPlaysCell = useCallback((cellInfo: TrackCell) => {
const track = cellInfo.row.original
const { plays } = track
// negative plays indicates the track is hidden
if (plays === -1) return '-'
return formatCount(track.plays)
}, [])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,12 @@ class CollectionPage extends Component<
handle: metadata.user.handle,
date: metadata.dateAdded || metadata.created_at,
time: metadata.duration,
plays: metadata.play_count
// for hidden tracks, we don't show the play_count and represent this
// as -1 for sorting. The tracks-table will render this as a dash.
plays:
metadata.is_unlisted && this.props.userId !== metadata.owner_id
? -1
: metadata.play_count
}))
}

Expand Down