Skip to content

Commit

Permalink
[PAY-2738] Public album with prem track always shows buy button (#8321)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan committed May 3, 2024
1 parent d897a98 commit 0b33e68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/web/src/components/tracks-table/TracksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type TracksTableProps = {
isPaginated?: boolean
isReorderable?: boolean
isAlbumPage?: boolean
isAlbumPremium?: boolean
isPremiumEnabled?: boolean
loading?: boolean
onClickFavorite?: (track: any) => void
Expand Down Expand Up @@ -131,6 +132,7 @@ export const TracksTable = ({
isPaginated = false,
isReorderable = false,
isAlbumPage = false,
isAlbumPremium = false,
fetchBatchSize,
fetchMoreTracks,
fetchPage,
Expand Down Expand Up @@ -467,13 +469,12 @@ export const TracksTable = ({
if (!isLocked || deleted || isOwner || !isPremiumEnabled) {
return null
}
// note: wrapping an if with this method does type casting for track.stream_conditions
if (isContentUSDCPurchaseGated(track.stream_conditions)) {
return (
<Button
size='small'
color='lightGreen'
className={styles.purchaseButton}
className={isAlbumPremium ? styles.purchaseButton : undefined}
onClick={(e) => {
e.stopPropagation()
onClickPurchase?.(track)
Expand All @@ -484,7 +485,7 @@ export const TracksTable = ({
)
}
},
[isPremiumEnabled, onClickPurchase, trackAccessMap, userId]
[isAlbumPremium, isPremiumEnabled, onClickPurchase, trackAccessMap, userId]
)

const renderTrackActions = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ const CollectionPage = ({
isAlbum ? messages.type.album : messages.type.playlist
}`}
isAlbumPage={isAlbum}
isAlbumPremium={
!!metadata && 'is_stream_gated' in metadata
? metadata?.is_stream_gated
: false
}
/>
</ClientOnly>
</div>
Expand Down

0 comments on commit 0b33e68

Please sign in to comment.