// @flow import * as ICONS from 'constants/icons'; import React, { useState, useEffect } from 'react'; import { regexInvalidURI } from 'lbry-redux'; import FileSelector from 'component/common/file-selector'; import Button from 'component/button'; import Card from 'component/common/card'; import Spinner from 'component/spinner'; type Props = { name: ?string, filePath: string | WebFile, isStillEditing: boolean, balance: number, updatePublishForm: ({}) => void, disabled: boolean, publishing: boolean, showToast: string => void, inProgress: boolean, clearPublish: () => void, }; function PublishFile(props: Props) { const { name, balance, filePath, isStillEditing, updatePublishForm, disabled, publishing, inProgress, clearPublish, } = props; const [duration, setDuration] = useState(0); const [size, setSize] = useState(0); const [oversized, setOversized] = useState(false); const [isVid, setIsVid] = useState(false); const RECOMMENDED_BITRATE = 6000000; const TV_PUBLISH_SIZE_LIMIT: number = 1073741824; const UPLOAD_SIZE_MESSAGE = 'Lbrytv uploads are limited to 1 GB. Download the app for unrestricted publishing.'; // clear warnings useEffect(() => { if (!filePath || filePath === '' || filePath.name === '') { setDuration(0); setSize(0); setIsVid(false); setOversized(false); } }, [filePath]); let currentFile = ''; if (filePath) { if (typeof filePath === 'string') { currentFile = filePath; } else { currentFile = filePath.name; } } function getBitrate(size, duration) { const s = Number(size); const d = Number(duration); if (s && d) { return (s * 8) / d; } else { return 0; } } function getMessage() { // @if TARGET='web' if (oversized) { return (

{__(UPLOAD_SIZE_MESSAGE)}{' '}