Skip to content

Commit

Permalink
[PAY-3036] Fix mobile header labels for premium content
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan committed May 16, 2024
1 parent 75f2bc6 commit 75c2288
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useEffect } from 'react'

import { useGetCurrentUserId, useGetPlaylistById } from '@audius/common/api'
import { Name, PlaybackSource, Status } from '@audius/common/models'
import type {
SmartCollectionVariant,
Expand Down Expand Up @@ -97,11 +98,14 @@ const useRefetchLineupOnTrackAdd = (
}, [previousTrackCount, trackCount, dispatch])
}

const getMessages = (collectionType: 'album' | 'playlist') => ({
const getMessages = (
collectionType: 'album' | 'playlist',
isPremium = false
) => ({
empty: `This ${collectionType} is empty. Start adding tracks to share it or make it public.`,
emptyPublic: `This ${collectionType} is empty`,
detailsPlaceholder: '---',
collectionType,
collectionType: `${isPremium ? 'premium ' : ''}${collectionType}`,
hiddenType: `Hidden ${collectionType}`
})

Expand Down Expand Up @@ -170,6 +174,16 @@ export const CollectionScreenDetailsTile = ({

const isReachable = useSelector(getIsReachable)

const { data: currentUserId } = useGetCurrentUserId({})
const { data: collection } = useGetPlaylistById(
{
playlistId: typeof collectionId === 'number' ? collectionId : -1,
currentUserId
},
{ disabled: typeof collectionId !== 'number' }
)
const isStreamGated = collection?.is_stream_gated

const trackUids = useSelector(selectTrackUids)
const collectionTrackCount = useSelector(selectTrackCount)
const trackCount = trackCountProp ?? collectionTrackCount
Expand All @@ -182,7 +196,7 @@ export const CollectionScreenDetailsTile = ({
const playingTrack = useSelector(getCurrentTrack)
const playingTrackId = playingTrack?.track_id
const firstTrack = useSelector(selectFirstTrack)
const messages = getMessages(isAlbum ? 'album' : 'playlist')
const messages = getMessages(isAlbum ? 'album' : 'playlist', isStreamGated)
useRefetchLineupOnTrackAdd(collectionId)

const play = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const messages = {
hiddenTrack: 'hidden track',
collectibleGated: 'collectible gated',
specialAccess: 'special access',
usdcPurchase: 'premium track',
premiumTrack: 'premium track',
generatedWithAi: 'generated with ai',
trackDeleted: 'track [deleted by artist]'
}
Expand Down Expand Up @@ -304,7 +304,13 @@ export const TrackScreenDetailsTile = ({
streamConditions={streamConditions}
user={user}
renderBottomContent={renderBottomContent}
headerText={isRemix ? messages.remix : messages.track}
headerText={
isRemix
? messages.remix
: isStreamGated
? messages.premiumTrack
: messages.track
}
hideFavorite={hideFavorite}
hideRepost={hideRepost}
hideShare={(is_unlisted && !isOwner) || !field_visibility?.share}
Expand Down

0 comments on commit 75c2288

Please sign in to comment.