Do not show shuffle option for empty collections.

This commit is contained in:
Franco Montenegro 2022-05-04 12:20:06 -03:00 committed by jessopb
parent 63ce691b90
commit 6108860063

View file

@ -110,6 +110,11 @@ function ClaimMenuList(props: Props) {
const [doShuffle, setDoShuffle] = React.useState(false); const [doShuffle, setDoShuffle] = React.useState(false);
const incognitoClaim = contentChannelUri && !contentChannelUri.includes('@'); const incognitoClaim = contentChannelUri && !contentChannelUri.includes('@');
const isChannel = !incognitoClaim && !contentSigningChannel; const isChannel = !incognitoClaim && !contentSigningChannel;
// $FlowFixMe
const claimLength = claim && claim.value && claim.value.claims && claim.value.claims.length;
// $FlowFixMe
const claimCount = editedCollection ? editedCollection.items.length : claimLength;
const isEmptyCollection = (Number(claimCount) || 0) <= 0;
const { channelName } = parseURI(contentChannelUri); const { channelName } = parseURI(contentChannelUri);
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0)); const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
const subscriptionLabel = repostedClaim const subscriptionLabel = repostedClaim
@ -297,18 +302,20 @@ function ClaimMenuList(props: Props) {
{__('View List')} {__('View List')}
</a> </a>
</MenuItem> </MenuItem>
<MenuItem {!isEmptyCollection && (
className="comment__menu-option" <MenuItem
onSelect={() => { className="comment__menu-option"
if (!resolvedList) fetchItems(); onSelect={() => {
setDoShuffle(true); if (!resolvedList) fetchItems();
}} setDoShuffle(true);
> }}
<div className="menu__link"> >
<Icon aria-hidden icon={ICONS.SHUFFLE} /> <div className="menu__link">
{__('Shuffle Play')} <Icon aria-hidden icon={ICONS.SHUFFLE} />
</div> {__('Shuffle Play')}
</MenuItem> </div>
</MenuItem>
)}
{isMyCollection && ( {isMyCollection && (
<> <>
<MenuItem <MenuItem