Skip to content

Commit

Permalink
[PAY-2868] Hide count stats if all zeros (#8396)
Browse files Browse the repository at this point in the history
  • Loading branch information
amendelsohn authored and dylanjeffers committed May 13, 2024
1 parent 03989a2 commit b392a11
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/mobile/src/components/details-tile/DetailsTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const DetailsTile = ({
streamConditions,
hideFavorite,
hideFavoriteCount,
hideListenCount,
hidePlayCount,
hideOverflow,
hideRepost,
hideRepostCount,
Expand Down Expand Up @@ -366,7 +366,6 @@ export const DetailsTile = ({
<DetailsTileStats
favoriteCount={saveCount}
hideFavoriteCount={hideFavoriteCount}
hideListenCount={hideListenCount}
hideRepostCount={hideRepostCount}
onPressFavorites={onPressFavorites}
onPressReposts={onPressReposts}
Expand Down Expand Up @@ -429,6 +428,7 @@ export const DetailsTile = ({
trackCount={trackCount}
releaseDate={releaseDate}
updatedAt={updatedAt}
hidePlayCount={hidePlayCount}
/>
{renderTags()}
<OfflineStatusRow contentId={contentId} isCollection={isCollection} />
Expand Down
11 changes: 6 additions & 5 deletions packages/mobile/src/components/details-tile/DetailsTileStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const messages = {
type DetailsTileStatsProps = {
favoriteCount?: number
hideFavoriteCount?: boolean
hideListenCount?: boolean
hideRepostCount?: boolean
onPressFavorites?: GestureResponderHandler
onPressReposts?: GestureResponderHandler
Expand All @@ -24,14 +23,16 @@ type DetailsTileStatsProps = {
*/
export const DetailsTileStats = ({
favoriteCount,
repostCount,
hideFavoriteCount,
hideListenCount,
hideRepostCount,
onPressFavorites,
onPressReposts,
repostCount
onPressReposts
}: DetailsTileStatsProps) => {
if (hideListenCount && hideFavoriteCount && hideRepostCount) {
if (
(hideFavoriteCount && hideRepostCount) ||
(!favoriteCount && !repostCount)
) {
return null
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type SecondaryStatsProps = {
trackCount?: number
releaseDate?: string
updatedAt?: string
hidePlayCount?: boolean
}

/**
Expand All @@ -47,7 +48,8 @@ export const SecondaryStats = ({
duration,
trackCount,
releaseDate,
updatedAt
updatedAt,
hidePlayCount
}: SecondaryStatsProps) => {
return (
<Flex gap='xs' w='100%'>
Expand All @@ -65,7 +67,7 @@ export const SecondaryStats = ({
? `${trackCount} ${pluralize(messages.trackCount, trackCount)}`
: null,
formatSecondsAsText(duration ?? 0),
playCount
playCount && !hidePlayCount
? `${playCount} ${pluralize(messages.playCount, playCount)}`
: null
]}
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/src/components/details-tile/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export type DetailsTileProps = {
/** Hide the favorite count */
hideFavoriteCount?: boolean

/** Hide the listen count */
hideListenCount?: boolean
/** Hide the play count */
hidePlayCount?: boolean

/** Hide the overflow menu button */
hideOverflow?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const CollectionScreenDetailsTile = ({
descriptionLinkPressSource='collection page'
duration={collectionDuration}
hideOverflow={hideOverflow || !isReachable}
hideListenCount={true}
hidePlayCount={true}
hasStreamAccess={hasStreamAccess}
streamConditions={streamConditions}
hideRepost={hideRepost || !isReachable}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export const TrackScreenDetailsTile = ({
hideShare={(is_unlisted && !isOwner) || !field_visibility?.share}
hideOverflow={!isReachable}
hideFavoriteCount={is_unlisted}
hideListenCount={
hidePlayCount={
(!isOwner && is_unlisted && !field_visibility?.play_count) ||
isStreamGated
}
Expand Down

0 comments on commit b392a11

Please sign in to comment.