use pending livestreams on dash, filter modes

This commit is contained in:
zeppi 2021-03-23 20:49:29 -04:00 committed by jessopb
parent 137c268a7b
commit 995f51711f
4 changed files with 44 additions and 37 deletions

View file

@ -8,7 +8,7 @@
File upload is carried out in the background by that function. File upload is carried out in the background by that function.
*/ */
import { SITE_NAME } from 'config'; import { SITE_NAME, ENABLE_NO_SOURCE_CLAIMS } from 'config';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { buildURI, isURIValid, isNameValid, THUMBNAIL_STATUSES } from 'lbry-redux'; import { buildURI, isURIValid, isNameValid, THUMBNAIL_STATUSES } from 'lbry-redux';
import Button from 'component/button'; import Button from 'component/button';
@ -32,14 +32,6 @@ import fs from 'fs';
import tempy from 'tempy'; import tempy from 'tempy';
// @endif // @endif
const MODES = Object.values(PUBLISH_MODES);
const MODE_TO_I18N_STR = {
[PUBLISH_MODES.FILE]: 'File',
[PUBLISH_MODES.POST]: 'Post --[noun, markdown post tab button]--',
[PUBLISH_MODES.LIVESTREAM]: 'Livestream --[noun, livestream tab button]--',
};
type Props = { type Props = {
disabled: boolean, disabled: boolean,
tags: Array<Tag>, tags: Array<Tag>,
@ -92,21 +84,6 @@ type Props = {
function PublishForm(props: Props) { function PublishForm(props: Props) {
// Detect upload type from query in URL // Detect upload type from query in URL
const { push, location } = useHistory();
const urlParams = new URLSearchParams(location.search);
const uploadType = urlParams.get('type');
// Component state
const [mode, setMode] = React.useState(uploadType || PUBLISH_MODES.FILE);
const [autoSwitchMode, setAutoSwitchMode] = React.useState(true);
// Used to check if the url name has changed:
// A new file needs to be provided
const [prevName, setPrevName] = React.useState(false);
// Used to check if the file has been modified by user
const [fileEdited, setFileEdited] = React.useState(false);
const [prevFileText, setPrevFileText] = React.useState('');
const { const {
thumbnail, thumbnail,
name, name,
@ -136,6 +113,31 @@ function PublishForm(props: Props) {
user, user,
} = props; } = props;
const { push, location } = useHistory();
const urlParams = new URLSearchParams(location.search);
const uploadType = urlParams.get('type');
// $FlowFixMe
const MODES =
ENABLE_NO_SOURCE_CLAIMS && user && user.experimental_ui
? Object.values(PUBLISH_MODES)
: Object.values(PUBLISH_MODES).filter((mode) => mode !== PUBLISH_MODES.LIVESTREAM);
const MODE_TO_I18N_STR = {
[PUBLISH_MODES.FILE]: 'File',
[PUBLISH_MODES.POST]: 'Post --[noun, markdown post tab button]--',
[PUBLISH_MODES.LIVESTREAM]: 'Livestream --[noun, livestream tab button]--',
};
// Component state
const [mode, setMode] = React.useState(uploadType || PUBLISH_MODES.FILE);
const [autoSwitchMode, setAutoSwitchMode] = React.useState(true);
// Used to check if the url name has changed:
// A new file needs to be provided
const [prevName, setPrevName] = React.useState(false);
// Used to check if the file has been modified by user
const [fileEdited, setFileEdited] = React.useState(false);
const [prevFileText, setPrevFileText] = React.useState('');
const TAGS_LIMIT = 5; const TAGS_LIMIT = 5;
const fileFormDisabled = mode === PUBLISH_MODES.FILE && !filePath; const fileFormDisabled = mode === PUBLISH_MODES.FILE && !filePath;
const emptyPostError = mode === PUBLISH_MODES.POST && (!fileText || fileText.trim() === ''); const emptyPostError = mode === PUBLISH_MODES.POST && (!fileText || fileText.trim() === '');
@ -396,9 +398,9 @@ function PublishForm(props: Props) {
setPrevFileText={setPrevFileText} setPrevFileText={setPrevFileText}
header={ header={
<> <>
{MODES.map((modeName, index) => !((index === 2) && user && user.experimental_ui) && ( {MODES.map((modeName) => (
<Button <Button
key={index} key={String(modeName)}
icon={modeName} icon={modeName}
label={__(MODE_TO_I18N_STR[String(modeName)] || '---')} label={__(MODE_TO_I18N_STR[String(modeName)] || '---')}
button="alt" button="alt"

View file

@ -11,20 +11,20 @@ import { useHistory } from 'react-router';
type Props = { type Props = {
uri: string, uri: string,
resolveUri: string => void, resolveUri: (string) => void,
claim: Claim, claim: Claim,
doPlayUri: string => void, doPlayUri: (string) => void,
costInfo: any, costInfo: any,
streamingUrl: string, streamingUrl: string,
doFetchCostInfoForUri: string => void, doFetchCostInfoForUri: (string) => void,
isResolvingUri: boolean, isResolvingUri: boolean,
blackListedOutpoints: Array<{ blackListedOutpoints: Array<{
txid: string, txid: string,
nout: number, nout: number,
}>, }>,
}; };
// $FlowFixMe apparently flow thinks this is wrong.
export const EmbedContext = React.createContext(); export const EmbedContext = React.createContext<any>();
const EmbedWrapperPage = (props: Props) => { const EmbedWrapperPage = (props: Props) => {
const { const {
resolveUri, resolveUri,
@ -54,7 +54,7 @@ const EmbedWrapperPage = (props: Props) => {
claim && claim &&
blackListedOutpoints && blackListedOutpoints &&
blackListedOutpoints.some( blackListedOutpoints.some(
outpoint => (outpoint) =>
(signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) || (signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) ||
(outpoint.txid === claim.txid && outpoint.nout === claim.nout) (outpoint.txid === claim.txid && outpoint.nout === claim.nout)
); );

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectMyChannelClaims, selectFetchingMyChannels } from 'lbry-redux'; import { selectMyChannelClaims, selectFetchingMyChannels, selectPendingClaims } from 'lbry-redux';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import LivestreamSetupPage from './view'; import LivestreamSetupPage from './view';
@ -7,6 +7,7 @@ const select = (state) => ({
channels: selectMyChannelClaims(state), channels: selectMyChannelClaims(state),
fetchingChannels: selectFetchingMyChannels(state), fetchingChannels: selectFetchingMyChannels(state),
activeChannelClaim: selectActiveChannelClaim(state), activeChannelClaim: selectActiveChannelClaim(state),
pendingClaims: selectPendingClaims(state),
}); });
export default connect(select)(LivestreamSetupPage); export default connect(select)(LivestreamSetupPage);

View file

@ -18,10 +18,11 @@ type Props = {
channels: Array<ChannelClaim>, channels: Array<ChannelClaim>,
fetchingChannels: boolean, fetchingChannels: boolean,
activeChannelClaim: ?ChannelClaim, activeChannelClaim: ?ChannelClaim,
pendingClaims: Array<Claim>,
}; };
export default function LivestreamSetupPage(props: Props) { export default function LivestreamSetupPage(props: Props) {
const { channels, fetchingChannels, activeChannelClaim } = props; const { channels, fetchingChannels, activeChannelClaim, pendingClaims } = props;
const [sigData, setSigData] = React.useState({ signature: undefined, signing_ts: undefined }); const [sigData, setSigData] = React.useState({ signature: undefined, signing_ts: undefined });
@ -57,6 +58,9 @@ export default function LivestreamSetupPage(props: Props) {
} }
const [livestreamClaims, setLivestreamClaims] = React.useState([]); const [livestreamClaims, setLivestreamClaims] = React.useState([]);
// $FlowFixMe
const pendingLiveStreamClaims = pendingClaims.filter((claim) => !(claim && claim.value && claim.value.source));
const totalLivestreamClaims = pendingLiveStreamClaims.concat(livestreamClaims);
React.useEffect(() => { React.useEffect(() => {
if (!activeChannelClaimStr) return; if (!activeChannelClaimStr) return;
@ -105,7 +109,7 @@ export default function LivestreamSetupPage(props: Props) {
<> <>
<ChannelSelector hideAnon /> <ChannelSelector hideAnon />
{streamKey && livestreamClaims.length > 0 && ( {streamKey && totalLivestreamClaims.length > 0 && (
<Card <Card
title={__('Your stream key')} title={__('Your stream key')}
actions={ actions={
@ -129,10 +133,10 @@ export default function LivestreamSetupPage(props: Props) {
/> />
)} )}
{livestreamClaims.length > 0 ? ( {totalLivestreamClaims.length > 0 ? (
<ClaimList <ClaimList
header={__('Your livestream uploads')} header={__('Your livestream uploads')}
uris={livestreamClaims.map((claim) => claim.permanent_url)} uris={totalLivestreamClaims.map((claim) => claim.permanent_url)}
/> />
) : ( ) : (
<Yrbl <Yrbl