From 9163df9311467d0e94b0f70b88cb57f0f359cef3 Mon Sep 17 00:00:00 2001 From: Dharit Tantiviramanond Date: Fri, 28 Jun 2024 09:47:53 -0400 Subject: [PATCH 1/2] [C-4583] Allow hidden tracks to be added to public playlists in UI --- .../AddToCollectionDrawer.tsx | 11 ++++++++++- .../desktop/AddToCollectionModal.tsx | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx b/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx index 301772937a2..cb68b442027 100644 --- a/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx +++ b/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx @@ -24,6 +24,8 @@ import { CollectionList } from '../collection-list' import { AddCollectionCard } from '../collection-list/AddCollectionCard' import { CollectionCard } from '../collection-list/CollectionCard' import { FilterInput } from '../filter-input' +import { useFeatureFlag } from '@audius/common/hooks' +import { FeatureFlags } from '@audius/common/services' const { addTrackToPlaylist, createAlbum, createPlaylist } = cacheCollectionsActions @@ -71,6 +73,9 @@ export const AddToCollectionDrawer = () => { const trackTitle = useSelector(getTrackTitle) const isTrackUnlisted = useSelector(getTrackIsUnlisted) const [filter, setFilter] = useState('') + const { isEnabled: isHiddenPaidScheduledEnabled } = useFeatureFlag( + FeatureFlags.HIDDEN_PAID_SCHEDULED + ) const messages = getMessages(collectionType) @@ -131,7 +136,11 @@ export const AddToCollectionDrawer = () => { if (!trackId) return // Don't add if the track is hidden, but collection is public - if (isTrackUnlisted && !item.is_private) { + if ( + !isHiddenPaidScheduledEnabled && + !isTrackUnlisted && + !item.is_private + ) { toast({ content: messages.hiddenAdd }) return } diff --git a/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx b/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx index e5dff8e0aba..0e0dbbf99e4 100644 --- a/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx +++ b/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx @@ -25,6 +25,8 @@ import { useCollectionCoverArt } from 'hooks/useCollectionCoverArt' import { collectionPage } from 'utils/route' import styles from './AddToCollectionModal.module.css' +import { useFlag } from 'hooks/useRemoteConfig' +import { FeatureFlags } from '@audius/common/services' const { getCollectionType, getTrackId, getTrackTitle, getTrackIsUnlisted } = addToCollectionUISelectors const { addTrackToPlaylist, createAlbum, createPlaylist } = @@ -55,6 +57,9 @@ const AddToCollectionModal = () => { const isAlbumType = collectionType === 'album' const account = useSelector(getAccountWithNameSortedPlaylistsAndAlbums) const [searchValue, setSearchValue] = useState('') + const { isEnabled: isHiddenPaidScheduledEnabled } = useFlag( + FeatureFlags.HIDDEN_PAID_SCHEDULED + ) const messages = getMessages(collectionType) @@ -168,7 +173,11 @@ const AddToCollectionModal = () => {
Date: Fri, 28 Jun 2024 10:00:05 -0400 Subject: [PATCH 2/2] lint --- .../add-to-collection-drawer/AddToCollectionDrawer.tsx | 5 +++-- .../add-to-collection/desktop/AddToCollectionModal.tsx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx b/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx index cb68b442027..c0f58b3580f 100644 --- a/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx +++ b/packages/mobile/src/components/add-to-collection-drawer/AddToCollectionDrawer.tsx @@ -1,7 +1,9 @@ import { useCallback, useMemo, useState } from 'react' +import { useFeatureFlag } from '@audius/common/hooks' import type { Collection } from '@audius/common/models' import { CreatePlaylistSource } from '@audius/common/models' +import { FeatureFlags } from '@audius/common/services' import type { CommonState } from '@audius/common/store' import { accountSelectors, @@ -24,8 +26,6 @@ import { CollectionList } from '../collection-list' import { AddCollectionCard } from '../collection-list/AddCollectionCard' import { CollectionCard } from '../collection-list/CollectionCard' import { FilterInput } from '../filter-input' -import { useFeatureFlag } from '@audius/common/hooks' -import { FeatureFlags } from '@audius/common/services' const { addTrackToPlaylist, createAlbum, createPlaylist } = cacheCollectionsActions @@ -171,6 +171,7 @@ export const AddToCollectionDrawer = () => { collectionType, isTrackUnlisted, messages, + isHiddenPaidScheduledEnabled, onClose, toast, dispatch diff --git a/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx b/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx index 0e0dbbf99e4..dafc2563969 100644 --- a/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx +++ b/packages/web/src/components/add-to-collection/desktop/AddToCollectionModal.tsx @@ -5,6 +5,7 @@ import { SquareSizes, Collection } from '@audius/common/models' +import { FeatureFlags } from '@audius/common/services' import { accountSelectors, cacheCollectionsActions, @@ -22,11 +23,10 @@ import DynamicImage from 'components/dynamic-image/DynamicImage' import SearchBar from 'components/search-bar/SearchBar' import { Tooltip } from 'components/tooltip' import { useCollectionCoverArt } from 'hooks/useCollectionCoverArt' +import { useFlag } from 'hooks/useRemoteConfig' import { collectionPage } from 'utils/route' import styles from './AddToCollectionModal.module.css' -import { useFlag } from 'hooks/useRemoteConfig' -import { FeatureFlags } from '@audius/common/services' const { getCollectionType, getTrackId, getTrackTitle, getTrackIsUnlisted } = addToCollectionUISelectors const { addTrackToPlaylist, createAlbum, createPlaylist } =