// @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 { COLLECTIONS_CONSTS } from 'lbry-redux'; import { formatLbryUrlForWeb } from 'util/url'; type Props = { uri: string, claim: StreamClaim, openModal: (id: string, { uri: string, claimIsMine?: boolean, isSupport?: boolean }) => void, myChannels: ?Array, doToast: ({ message: string }) => void, claimIsPending: boolean, isMyCollection: boolean, collectionId: string, showInfo: boolean, setShowInfo: (boolean) => void, collectionHasEdits: boolean, isBuiltin: boolean, doToggleShuffleList: (string, boolean) => void, doToggleLoopList: (string, boolean) => void, playNextUri: string, playNextClaim: StreamClaim, doPlayUri: (string) => void, doSetPlayingUri: (string) => void, firstItem: string, }; function CollectionActions(props: Props) { const { uri, openModal, claim, claimIsPending, isMyCollection, collectionId, showInfo, setShowInfo, collectionHasEdits, isBuiltin, doToggleShuffleList, doToggleLoopList, playNextUri, playNextClaim, doPlayUri, doSetPlayingUri, firstItem, } = 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? const doPlay = React.useCallback( (uri) => { const collectionParams = new URLSearchParams(); collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId); const navigateUrl = formatLbryUrlForWeb(uri) + `?` + collectionParams.toString(); push(navigateUrl); doSetPlayingUri(uri); doPlayUri(uri); }, [collectionId, push, doSetPlayingUri, doPlayUri] ); React.useEffect(() => { if (playNextClaim && doShuffle) { setDoShuffle(false); doPlay(playNextUri); } }, [doPlay, doShuffle, playNextClaim, playNextUri]); const lhsSection = ( <>