Skip to content

Commit

Permalink
[C-3513] Private albums + show PublishButton for albums (#7055)
Browse files Browse the repository at this point in the history
  • Loading branch information
amendelsohn authored Jan 3, 2024
1 parent 5c034eb commit 7af8ba5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
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

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

0 comments on commit 7af8ba5

Please sign in to comment.