use has_no_source to check if claim is a livestream

This commit is contained in:
Sean Yesmunt 2021-03-17 14:57:27 -04:00 committed by DispatchCommit
parent e5fc28821a
commit 0f24f3fdfd
9 changed files with 14 additions and 36 deletions

View file

@ -1,9 +1,10 @@
import { connect } from 'react-redux';
import { makeSelectMediaTypeForUri } from 'lbry-redux';
import { makeSelectMediaTypeForUri, makeSelectClaimHasSource } from 'lbry-redux';
import FileType from './view';
const select = (state, props) => ({
mediaType: makeSelectMediaTypeForUri(props.uri)(state),
isLivestream: !makeSelectClaimHasSource(props.uri)(state),
});
export default connect(select)(FileType);

View file

@ -6,16 +6,17 @@ import Icon from 'component/common/icon';
type Props = {
uri: string,
mediaType: string,
isLivestream: boolean,
};
function FileType(props: Props) {
const { mediaType } = props;
const { mediaType, isLivestream } = props;
if (mediaType === 'image') {
return <Icon icon={ICONS.IMAGE} />;
} else if (mediaType === 'audio') {
return <Icon icon={ICONS.AUDIO} />;
} else if (mediaType === 'video') {
} else if (mediaType === 'video' || isLivestream) {
return <Icon icon={ICONS.VIDEO} />;
} else if (mediaType === 'text') {
return <Icon icon={ICONS.TEXT} />;

View file

@ -1,5 +1,4 @@
// @flow
import { LIVE_STREAM_TAG } from 'constants/livestream';
import React from 'react';
import Card from 'component/common/card';
import ClaimPreview from 'component/claimPreview';
@ -18,7 +17,7 @@ export default function LivestreamLink(props: Props) {
React.useEffect(() => {
Lbry.claim_search({
channel_ids: [livestreamChannelId],
any_tags: [LIVE_STREAM_TAG],
has_no_source: true,
claim_type: ['stream'],
})
.then((res) => {

View file

@ -328,7 +328,6 @@ function PublishFile(props: Props) {
const isPublishFile = mode === PUBLISH_MODES.FILE;
const isPublishPost = mode === PUBLISH_MODES.POST;
const isPublishLivestream = mode === PUBLISH_MODES.LIVESTREAM;
return (
<Card
@ -357,7 +356,7 @@ function PublishFile(props: Props) {
value={title}
onChange={handleTitleChange}
/>
{(isPublishFile || isPublishLivestream) && (
{isPublishFile && (
<FileSelector
label={__('File')}
disabled={disabled}
@ -366,13 +365,6 @@ function PublishFile(props: Props) {
/>
)}
{isPublishLivestream && (
<div className="help--warning">
While livestreaming is in beta, you still need to choose a file to upload. Please choose a small file. No
one will see this file.
</div>
)}
{isPublishPost && (
<PostEditor
label={__('Post --[noun, markdown post tab button]--')}

View file

@ -135,7 +135,7 @@ function PublishForm(props: Props) {
} = props;
const TAGS_LIMIT = 5;
const fileFormDisabled = (mode === PUBLISH_MODES.FILE || mode === PUBLISH_MODES.LIVESTREAM) && !filePath;
const fileFormDisabled = mode === PUBLISH_MODES.FILE && !filePath;
const emptyPostError = mode === PUBLISH_MODES.POST && (!fileText || fileText.trim() === '');
const formDisabled = (fileFormDisabled && !editingURI) || emptyPostError || publishing;
const isInProgress = filePath || editingURI || name || title;
@ -285,7 +285,7 @@ function PublishForm(props: Props) {
if (!uploadType) return;
const newParams = new URLSearchParams();
newParams.set('type', mode.toLowerCase());
history.push({search: newParams.toString()});
history.push({ search: newParams.toString() });
}, [mode, uploadType]);
// @if TARGET='web'
@ -357,11 +357,6 @@ function PublishForm(props: Props) {
runPublish = true;
}
// (Try to) Prevent an anon livestream claim
if (mode === PUBLISH_MODES.LIVESTREAM) {
updatePublishForm({ channel: activeChannelName });
}
if (runPublish) {
if (enablePublishPreview) {
setPreviewing(true);
@ -387,10 +382,7 @@ function PublishForm(props: Props) {
// Editing claim uri
return (
<div className="card-stack">
<ChannelSelect
hideAnon={mode === PUBLISH_MODES.LIVESTREAM}
disabled={disabled}
/>
<ChannelSelect hideAnon={mode === PUBLISH_MODES.LIVESTREAM} disabled={disabled} />
<PublishFile
uri={uri}

View file

@ -1,4 +1,2 @@
export const LIVE_STREAM_TAG = 'odysee-livestream';
export const BITWAVE_EMBED_URL = 'https://bitwave.tv/embed';
export const BITWAVE_API = 'https://api.bitwave.tv/v1/channels';

View file

@ -1,5 +1,5 @@
// @flow
// import { LIVE_STREAM_TAG, BITWAVE_API } from 'constants/livestream';
// import { BITWAVE_API } from 'constants/livestream';
import React from 'react';
import Page from 'component/page';
import LivestreamLayout from 'component/livestreamLayout';

View file

@ -60,10 +60,6 @@ export default function LivestreamSetupPage(props: Props) {
}`;
}
/******/
const LIVE_STREAM_TAG = 'odysee-livestream';
const [isFetching, setIsFetching] = React.useState(true);
const [isLive, setIsLive] = React.useState(false);
const [livestreamClaims, setLivestreamClaims] = React.useState([]);
@ -75,7 +71,7 @@ export default function LivestreamSetupPage(props: Props) {
Lbry.claim_search({
channel_ids: [channelClaim.claim_id],
any_tags: [LIVE_STREAM_TAG],
has_no_source: true,
claim_type: ['stream'],
})
.then((res) => {

View file

@ -1,7 +1,6 @@
import { DOMAIN } from 'config';
import { connect } from 'react-redux';
import { PAGE_SIZE } from 'constants/claim';
import { LIVE_STREAM_TAG } from 'constants/livestream';
import {
doResolveUri,
makeSelectClaimForUri,
@ -12,6 +11,7 @@ import {
makeSelectClaimIsMine,
makeSelectClaimIsPending,
makeSelectTagInClaimOrChannelForUri,
makeSelectClaimHasSource,
} from 'lbry-redux';
import { makeSelectChannelInSubscriptions } from 'redux/selectors/subscriptions';
import { selectBlackListedOutpoints } from 'lbryinc';
@ -62,8 +62,7 @@ const select = (state, props) => {
title: makeSelectTitleForUri(uri)(state),
claimIsMine: makeSelectClaimIsMine(uri)(state),
claimIsPending: makeSelectClaimIsPending(uri)(state),
// Change to !makeSelectClaimHasSource()
isLivestream: makeSelectTagInClaimOrChannelForUri(uri, LIVE_STREAM_TAG)(state),
isLivestream: !makeSelectClaimHasSource(uri)(state),
};
};