Skip to content
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-2814] Omit favorite and repost buttons for unowned albums #8357

Merged
merged 2 commits into from
May 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const CollectionScreenDetailsTile = ({
isOwner,
hideOverflow,
hideRepost,
hideFavorite,
hasStreamAccess,
streamConditions,
ddexApp,
Expand Down Expand Up @@ -291,7 +292,8 @@ export const CollectionScreenDetailsTile = ({
hideListenCount={true}
hasStreamAccess={hasStreamAccess}
streamConditions={streamConditions}
hideRepost={hideRepost || !isReachable}
hideFavorite={hideFavorite || !hasStreamAccess}
hideRepost={hideRepost || !isReachable || !hasStreamAccess}
Comment on lines +295 to +296
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use isReachable for repost but not for favorite? Shouldn't they be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you are allowed to unfavorite things while offline to remove them from your library and downloads

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you shouldn't be able to access the collection page while offline unless it's been downloaded and is already part of your library

isPlaying={isPlaying && isQueued}
isPreviewing={isPreviewing && isQueued}
isPublished={!isPrivate || isPublishing}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ const CollectionArtCard = g(
has_current_user_saved,
repost_count,
save_count,
permalink
permalink,
access
} = collection
const { user_id, name, handle } = user
const hasStreamAccess = access?.stream

const [isPerspectiveDisabled, setIsPerspectiveDisabled] = useState(false)

Expand Down Expand Up @@ -144,8 +146,8 @@ const CollectionArtCard = g(
playlistName: playlist_name,
isOwner: currentUserId === user_id,
includeShare: true,
includeRepost: true,
includeSave: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this was broken before because the prop had been renamed to includeFavorite BUT we cast through as unknown as CollectionMenuProps here so we weren't warned about it

includeRepost: hasStreamAccess,
includeFavorite: hasStreamAccess,
includeVisitPage: true,
isFavorited: has_current_user_saved,
isReposted: has_current_user_reposted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ export const OverflowMenuButton = (props: OverflowMenuButtonProps) => {
is_private,
playlist_owner_id,
has_current_user_saved,
permalink
permalink,
access
} =
(useSelector((state: CommonState) =>
getCollection(state, { id: collectionId })
) as Collection) ?? {}

const owner = useSelector(getUser) as User
const isFollowing = owner?.does_current_user_follow
const hasStreamAccess = access?.stream

const handleFollow = useCallback(() => {
if (isFollowing) {
Expand Down Expand Up @@ -70,7 +72,7 @@ export const OverflowMenuButton = (props: OverflowMenuButtonProps) => {
mount: 'page',
isOwner,
includeEmbed: true,
includeSave: false,
includeFavorite: hasStreamAccess,
includeVisitPage: false,
isPublic: !is_private,
extraMenuItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ export const ViewerActionButtons = (props: ViewerActionButtonsProps) => {
getCollection(state, { id: collectionId })
) as Collection | null

const { track_count, is_private } = collection ?? {}
const { track_count, is_private, access } = collection ?? {}
const isDisabled = !collection || track_count === 0 || is_private
const hasStreamAccess = access?.stream

return (
<>
<RepostButton disabled={isDisabled} collectionId={collectionId} />
<FavoriteButton disabled={isDisabled} collectionId={collectionId} />
{hasStreamAccess ? (
<>
<RepostButton disabled={isDisabled} collectionId={collectionId} />
<FavoriteButton disabled={isDisabled} collectionId={collectionId} />
</>
) : null}

<ShareButton disabled={isDisabled} collectionId={collectionId} />
<ClientOnly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ const CollectionHeader = ({

const onClickOverflow = () => {
const overflowActions = [
isOwner || !isPublished
isOwner || !isPublished || !hasStreamAccess
? null
: isReposted
? OverflowAction.UNREPOST
: OverflowAction.REPOST,
isOwner || !isPublished
isOwner || !isPublished || !hasStreamAccess
? null
: isSaved
? OverflowAction.UNFAVORITE
Expand Down Expand Up @@ -277,8 +277,8 @@ const CollectionHeader = ({
onRepost={onRepost}
onClickOverflow={onClickOverflow}
onClickEdit={handleClickEdit}
showFavorite={!!onSave && !isOwner}
showRepost={variant !== Variant.SMART && !isOwner}
showFavorite={!!onSave && !isOwner && hasStreamAccess}
showRepost={variant !== Variant.SMART && !isOwner && hasStreamAccess}
showShare={variant !== Variant.SMART || type === 'Audio NFT Playlist'}
showOverflow={variant !== Variant.SMART}
darkMode={isDarkMode()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const CollectionsTableOverflowMenuButton = (
includeVisitArtistPage: false,
includeShare: true,
includeEdit: true,
includeSave: false,
includeFavorite: false,
isPublic: !isPrivate,
isOwner: currentUserId === playlistOwnerId,
permalink
Expand Down