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

[C-3513] Private albums + show PublishButton for albums #7055

Merged
merged 2 commits into from
Jan 3, 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
3 changes: 0 additions & 3 deletions packages/common/src/services/audius-backend/AudiusBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,9 +1349,6 @@ export const audiusBackend = ({
trackIds: ID[] = [],
isPrivate = true
) {
// Creating an album is automatically public.
if (isAlbum) isPrivate = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Good looks


try {
const web3 = await audiusLibs.web3Manager.getWeb3()
const currentBlockNumber = await web3.eth.getBlockNumber()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const OwnerActionButtons = (props: OwnerActionButtonProps) => {
const collection = useSelector((state: CommonState) =>
getCollection(state, { id: collectionId })
) as Collection
const { track_count, is_private, is_album } = collection ?? {}
const { track_count, is_private } = collection ?? {}

const isDisabled = track_count === 0

Expand All @@ -39,7 +39,7 @@ export const OwnerActionButtons = (props: OwnerActionButtonProps) => {
}
widthToHideText={BUTTON_COLLAPSE_WIDTHS.third}
/>
{is_private && !is_album ? (
{is_private ? (
<PublishButton
collectionId={collectionId}
widthToHideText={BUTTON_COLLAPSE_WIDTHS.fourth}
Expand Down
12 changes: 7 additions & 5 deletions packages/web/src/components/collection/desktop/PublishButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const messages = {
publish: 'Make Public',
publishing: 'Making Public',
emptyPlaylistTooltipText: 'You must add at least 1 song.',
hiddenTracksTooltipText:
'You cannot make a playlist with hidden tracks public.'
hiddenTracksTooltipText: (collectionType: 'playlist' | 'album') =>
`You cannot make a ${collectionType} with hidden tracks public.`
}

type PublishButtonProps = Partial<ButtonProps> & {
Expand All @@ -33,8 +33,8 @@ type PublishButtonProps = Partial<ButtonProps> & {

export const PublishButton = (props: PublishButtonProps) => {
const { collectionId, ...other } = props
const { _is_publishing, track_count } = useSelector((state: CommonState) =>
getCollection(state, { id: collectionId })
const { _is_publishing, track_count, is_album } = useSelector(
(state: CommonState) => getCollection(state, { id: collectionId })
) as Collection
const hasHiddenTracks = useSelector((state: CommonState) =>
getCollecitonHasHiddenTracks(state, { id: collectionId })
Expand Down Expand Up @@ -73,7 +73,9 @@ export const PublishButton = (props: PublishButtonProps) => {
<Tooltip
text={
hasHiddenTracks
? messages.hiddenTracksTooltipText
? messages.hiddenTracksTooltipText(
is_album ? 'album' : 'playlist'
)
: messages.emptyPlaylistTooltipText
}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useCallback } from 'react'

import { cacheCollectionsActions } from '@audius/common'
import {
Collection,
CommonState,
cacheCollectionsActions,
collectionPageSelectors
} from '@audius/common'
import {
Button,
ButtonType,
Expand All @@ -13,16 +18,17 @@ import {
ModalProps,
ModalTitle
} from '@audius/stems'
import { useDispatch } from 'react-redux'
import { useDispatch, useSelector } from 'react-redux'

import styles from './PublishConfirmationModal.module.css'
const { getCollection } = collectionPageSelectors

const { publishPlaylist } = cacheCollectionsActions

const messages = {
title: 'Make Public',
description:
'Are you sure you want to make this playlist public? It will be shared to your feed and your subscribed followers will be notified.',
description: (collectionType: 'album' | 'playlist') =>
`Are you sure you want to make this ${collectionType} public? It will be shared to your feed and your subscribed followers will be notified.`,
cancel: 'Cancel',
publish: 'Make Public'
}
Expand All @@ -38,6 +44,10 @@ export const PublishConfirmationModal = (
const { onClose } = other
const dispatch = useDispatch()

const { is_album } = useSelector((state: CommonState) =>
getCollection(state, { id: collectionId })
) as Collection

const handlePublish = useCallback(() => {
dispatch(publishPlaylist(collectionId))
onClose()
Expand All @@ -52,7 +62,9 @@ export const PublishConfirmationModal = (
/>
</ModalHeader>
<ModalContent>
<ModalContentText>{messages.description}</ModalContentText>
<ModalContentText>
{messages.description(is_album ? 'album' : 'playlist')}
</ModalContentText>
</ModalContent>
<ModalFooter className={styles.footer}>
<Button
Expand Down