Skip to content

Commit

Permalink
[C-2461, C-2476] Prevent user from dragging hidden tracks to public p…
Browse files Browse the repository at this point in the history
…laylists (#3535)
  • Loading branch information
Kyle-Shanks committed Jun 7, 2023
1 parent f2ad1ce commit 4c22b12
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
Name,
ID,
cacheCollectionsActions,
cacheTracksSelectors,
cacheCollectionsSelectors,
playlistLibraryActions,
PlaylistLibraryKind,
PlaylistLibraryID,
Expand Down Expand Up @@ -32,7 +34,9 @@ import { DeleteCollectionConfirmationModal } from './DeleteCollectionConfirmatio
import { NavItemKebabButton } from './NavItemKebabButton'
import { PlaylistUpdateDot } from './PlaylistUpdateDot'

const { getTrack } = cacheTracksSelectors
const { addTrackToPlaylist } = cacheCollectionsActions
const { getCollection } = cacheCollectionsSelectors
const { reorder } = playlistLibraryActions
const { requestOpen } = shareModalUIActions

Expand Down Expand Up @@ -142,11 +146,21 @@ export const CollectionNavItem = (props: CollectionNavItemProps) => {

const draggingKind = useSelector(selectDraggingKind)
const draggingId = useSelector(selectDraggingId)
const track = useSelector((state) =>
getTrack(state, { id: typeof draggingId === 'string' ? null : draggingId })
)
const collection = useSelector((state) =>
getCollection(state, { id: typeof id === 'string' ? null : id })
)

const hiddenTrackCheck =
!!track && !!collection && track?.is_unlisted && !collection?.is_private

const isDisabled =
(draggingKind === 'track' && !isOwned) ||
draggingId === id ||
(draggingKind === 'playlist-folder' && level > 0)
(draggingKind === 'playlist-folder' && level > 0) ||
hiddenTrackCheck

if (!name || !url) return null

Expand Down

0 comments on commit 4c22b12

Please sign in to comment.