// @flow import * as PAGES from 'constants/pages'; import * as MODALS from 'constants/modal_types'; import * as ICONS from 'constants/icons'; import React from 'react'; import Button from 'component/button'; import { useIsMobile } from 'effects/use-screensize'; import ClaimSupportButton from 'component/claimSupportButton'; import FileReactions from 'component/fileReactions'; import { useHistory } from 'react-router'; import { EDIT_PAGE, PAGE_VIEW_QUERY } from 'page/collection/view'; import classnames from 'classnames'; import { ENABLE_FILE_REACTIONS } from 'config'; import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url'; type Props = { uri: string, claim: StreamClaim, openModal: (id: string, {}) => void, claimIsPending: boolean, isMyCollection: boolean, collectionId: string, showInfo: boolean, setShowInfo: (boolean) => void, showEdit: boolean, setShowEdit: (boolean) => void, collectionHasEdits: boolean, isBuiltin: boolean, doToggleShuffleList: (string, boolean) => void, playNextUri: string, firstItem: string, }; function CollectionActions(props: Props) { const { uri, openModal, claim, claimIsPending, isMyCollection, collectionId, showInfo, setShowInfo, collectionHasEdits, isBuiltin, doToggleShuffleList, playNextUri, firstItem, showEdit, setShowEdit, } = props; const [doShuffle, setDoShuffle] = React.useState(false); const { push } = useHistory(); const isMobile = useIsMobile(); const claimId = claim && claim.claim_id; const webShareable = true; // collections have cost? /* A bit too much dependency with both ordering and shuffling depending on a single list item index selector For now when they click edit, we'll toggle shuffle off for them. */ const handleSetShowEdit = (setting) => { doToggleShuffleList(collectionId, false); setShowEdit(setting); }; const handlePublishMode = () => { doToggleShuffleList(collectionId, false); push(`?${PAGE_VIEW_QUERY}=${EDIT_PAGE}`); }; const doPlay = React.useCallback( (playUri) => { const navigateUrl = formatLbryUrlForWeb(playUri); push({ pathname: navigateUrl, search: generateListSearchUrlParams(collectionId), state: { forceAutoplay: true }, }); }, [collectionId, push] ); React.useEffect(() => { if (playNextUri && doShuffle) { setDoShuffle(false); doPlay(playNextUri); } }, [doPlay, doShuffle, playNextUri]); const lhsSection = ( <>