// @flow import * as ICONS from 'constants/icons'; import * as MODALS from 'constants/modal_types'; import React from 'react'; import classnames from 'classnames'; import { Menu, MenuButton, MenuList, MenuItem } from '@reach/menu-button'; import Icon from 'component/common/icon'; import * as PAGES from 'constants/pages'; import { useHistory } from 'react-router'; import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url'; type Props = { inline?: boolean, doOpenModal: (string, {}) => void, collectionName?: string, collectionId: string, playNextUri: string, doToggleShuffleList: (string) => void, }; function CollectionMenuList(props: Props) { const { inline = false, collectionId, collectionName, doOpenModal, playNextUri, doToggleShuffleList } = props; const [doShuffle, setDoShuffle] = React.useState(false); const { push } = useHistory(); React.useEffect(() => { if (playNextUri && doShuffle) { setDoShuffle(false); const navigateUrl = formatLbryUrlForWeb(playNextUri); push({ pathname: navigateUrl, search: generateListSearchUrlParams(collectionId), state: { forceAutoplay: true }, }); } }, [collectionId, doShuffle, playNextUri, push]); return ( { e.stopPropagation(); e.preventDefault(); }} > {collectionId && collectionName && ( <> push(`/$/${PAGES.LIST}/${collectionId}`)}> {__('View List')} { doToggleShuffleList(collectionId); setDoShuffle(true); }} >
{__('Shuffle Play')}
push(`/$/${PAGES.LIST}/${collectionId}?view=edit`)} >
{__('Publish List')}
doOpenModal(MODALS.COLLECTION_DELETE, { collectionId })} >
{__('Delete List')}
)}
); } export default CollectionMenuList;