-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PAY-3036] Fix mobile header labels for premium content #8520
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
|
@@ -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}` | ||
}) | ||
|
||
|
@@ -170,6 +174,19 @@ export const CollectionScreenDetailsTile = ({ | |
|
||
const isReachable = useSelector(getIsReachable) | ||
|
||
const { data: currentUserId } = useGetCurrentUserId({}) | ||
// Since we're supporting SmartCollections, need to explicitly check that | ||
// collectionId is a number before fetching the playlist. -1 is a placeholder, | ||
// the request should not go out as the hook is disabled in that case. | ||
const { data: collection } = useGetPlaylistById( | ||
{ | ||
playlistId: typeof collectionId === 'number' ? collectionId : -1, | ||
currentUserId | ||
}, | ||
{ disabled: typeof collectionId !== 'number' } | ||
) | ||
const isStreamGated = collection?.is_stream_gated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This won't always resolve to a boolean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wdym? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, so |
||
|
||
const trackUids = useSelector(selectTrackUids) | ||
const collectionTrackCount = useSelector(selectTrackCount) | ||
const trackCount = trackCountProp ?? collectionTrackCount | ||
|
@@ -182,7 +199,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( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite following, whats the scenario for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CollectionId
could be aSmartCollectionVariant
in which case we don't want to do anything. Ideally these cases would be split out into different components.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ID
is code smell.