better handle reposts

This commit is contained in:
saltrafael 2021-06-14 08:44:51 -03:00 committed by jessopb
parent 6629ea6041
commit 32d2ac2fc9
3 changed files with 13 additions and 11 deletions

View file

@ -79,7 +79,7 @@ const ClaimCollectionAdd = (props: Props) => {
.filter((list) => (isChannel ? list.type === 'collection' : list.type === 'playlist')) .filter((list) => (isChannel ? list.type === 'collection' : list.type === 'playlist'))
.map((l) => { .map((l) => {
const { id } = l; const { id } = l;
return <CollectionSelectItem collectionId={id} uri={permanentUrl} key={id} category={'builtin'} />; return <CollectionSelectItem claim={claim} collectionId={id} uri={permanentUrl} key={id} category={'builtin'} />;
})} })}
{unpublished && {unpublished &&
(Object.values(unpublished): any) (Object.values(unpublished): any)
@ -88,7 +88,7 @@ const ClaimCollectionAdd = (props: Props) => {
.map((l) => { .map((l) => {
const { id } = l; const { id } = l;
return ( return (
<CollectionSelectItem collectionId={id} uri={permanentUrl} key={id} category={'unpublished'} /> <CollectionSelectItem claim={claim} collectionId={id} uri={permanentUrl} key={id} category={'unpublished'} />
); );
})} })}
{published && {published &&
@ -96,7 +96,7 @@ const ClaimCollectionAdd = (props: Props) => {
// $FlowFixMe // $FlowFixMe
const { id } = l; const { id } = l;
return ( return (
<CollectionSelectItem collectionId={id} uri={permanentUrl} key={id} category={'published'} /> <CollectionSelectItem claim={claim} collectionId={id} uri={permanentUrl} key={id} category={'published'} />
); );
})} })}
</div> </div>

View file

@ -80,6 +80,8 @@ function ClaimMenuList(props: Props) {
doChannelUnsubscribe, doChannelUnsubscribe,
isChannelPage = false, isChannelPage = false,
} = props; } = props;
const repostedContent = claim && claim.reposted_claim;
const contentClaim = repostedContent || claim;
const incognito = channelUri && !(channelUri.includes('@')); const incognito = channelUri && !(channelUri.includes('@'));
const signingChannel = claim && (claim.signing_channel || claim); const signingChannel = claim && (claim.signing_channel || claim);
const permanentUrl = String(channelUri); const permanentUrl = String(channelUri);
@ -96,12 +98,13 @@ function ClaimMenuList(props: Props) {
const isCollectionClaim = claim && claim.value_type === 'collection'; const isCollectionClaim = claim && claim.value_type === 'collection';
// $FlowFixMe // $FlowFixMe
const isPlayable = const isPlayable =
claim && contentClaim &&
!claim.repost_url &&
// $FlowFixMe // $FlowFixMe
claim.value.stream_type && contentClaim.value &&
// $FlowFixMe // $FlowFixMe
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video'); contentClaim.value.stream_type &&
// $FlowFixMe
(contentClaim.value.stream_type === 'audio' || contentClaim.value.stream_type === 'video');
function handleFollow() { function handleFollow() {
const { channelName } = parseURI(permanentUrl); const { channelName } = parseURI(permanentUrl);
@ -172,7 +175,8 @@ function ClaimMenuList(props: Props) {
} }
function handleReportContent() { function handleReportContent() {
push(`/$/${PAGES.REPORT_CONTENT}?claimId=${claim.claim_id}`); // $FlowFixMe
push(`/$/${PAGES.REPORT_CONTENT}?claimId=${(repostedContent && repostedContent.claim_id) || claim.claim_id}`);
} }
return ( return (
@ -218,7 +222,7 @@ function ClaimMenuList(props: Props) {
}), }),
}); });
doCollectionEdit(COLLECTIONS_CONSTS.WATCH_LATER_ID, { doCollectionEdit(COLLECTIONS_CONSTS.WATCH_LATER_ID, {
claims: [claim], claims: [contentClaim],
remove: hasClaimInWatchLater, remove: hasClaimInWatchLater,
type: 'playlist', type: 'playlist',
}); });

View file

@ -1,7 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doCollectionEdit, doCollectionEdit,
makeSelectClaimForUri,
makeSelectCollectionForId, makeSelectCollectionForId,
makeSelectClaimIsPending, makeSelectClaimIsPending,
makeSelectCollectionForIdHasClaimUrl, makeSelectCollectionForIdHasClaimUrl,
@ -12,7 +11,6 @@ const select = (state, props) => {
return { return {
collection: makeSelectCollectionForId(props.collectionId)(state), collection: makeSelectCollectionForId(props.collectionId)(state),
hasClaim: makeSelectCollectionForIdHasClaimUrl(props.collectionId, props.uri)(state), hasClaim: makeSelectCollectionForIdHasClaimUrl(props.collectionId, props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
collectionPending: makeSelectClaimIsPending(props.collectionId)(state), collectionPending: makeSelectClaimIsPending(props.collectionId)(state),
}; };
}; };