From 60ff45e2246a223b4a7a6d05851930eec6d5710c Mon Sep 17 00:00:00 2001 From: zeppi Date: Mon, 12 Apr 2021 11:59:33 -0400 Subject: [PATCH] move file size limit to conig --- .env.defaults | 1 + config.js | 1 + ui/component/publishFile/view.jsx | 33 +++++++++++++++---------------- ui/component/publishForm/view.jsx | 3 +-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.env.defaults b/.env.defaults index 556e4ca44..c6c322dcd 100644 --- a/.env.defaults +++ b/.env.defaults @@ -33,6 +33,7 @@ ENABLE_CREATOR_REACTIONS=false ENABLE_NO_SOURCE_CLAIMS=false ENABLE_PREROLL_ADS=false CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS=4 +WEB_PUBLISH_SIZE_LIMIT_GB=4 CHANNEL_STAKED_LEVEL_LIVESTREAM=5 # OG diff --git a/config.js b/config.js index 8203652d9..db8d01cbb 100644 --- a/config.js +++ b/config.js @@ -38,6 +38,7 @@ const config = { ENABLE_NO_SOURCE_CLAIMS: process.env.ENABLE_NO_SOURCE_CLAIMS === 'true', ENABLE_PREROLL_ADS: process.env.ENABLE_PREROLL_ADS === 'true', CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS: process.env.CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, + WEB_PUBLISH_SIZE_LIMIT_GB: process.env.WEB_PUBLISH_SIZE_LIMIT_GB, CHANNEL_STAKED_LEVEL_LIVESTREAM: process.env.CHANNEL_STAKED_LEVEL_LIVESTREAM, SIMPLE_SITE: process.env.SIMPLE_SITE === 'true', SHOW_ADS: process.env.SHOW_ADS === 'true', diff --git a/ui/component/publishFile/view.jsx b/ui/component/publishFile/view.jsx index 01e6c7c4e..e0a1280ce 100644 --- a/ui/component/publishFile/view.jsx +++ b/ui/component/publishFile/view.jsx @@ -1,5 +1,5 @@ // @flow -import { SITE_NAME } from 'config'; +import { SITE_NAME, WEB_PUBLISH_SIZE_LIMIT_GB } from 'config'; import type { Node } from 'react'; import * as ICONS from 'constants/icons'; import React, { useState, useEffect } from 'react'; @@ -86,9 +86,8 @@ function PublishFile(props: Props) { const SOURCE_UPLOAD = 'upload'; const RECOMMENDED_BITRATE = 6000000; - const TV_PUBLISH_SIZE_LIMIT: number = 4294967296; - const TV_PUBLISH_SIZE_LIMIT_STR_GB = '4'; - const PAGE_SIZE = 4; + const TV_PUBLISH_SIZE_LIMIT_BYTES = WEB_PUBLISH_SIZE_LIMIT_GB * 1073741824; + const TV_PUBLISH_SIZE_LIMIT_GB_STR = String(WEB_PUBLISH_SIZE_LIMIT_GB); const PROCESSING_MB_PER_SECOND = 0.5; const MINUTES_THRESHOLD = 30; @@ -96,6 +95,16 @@ function PublishFile(props: Props) { const MARKDOWN_FILE_EXTENSIONS = ['txt', 'md', 'markdown']; const sizeInMB = Number(size) / 1000000; const secondsToProcess = sizeInMB / PROCESSING_MB_PER_SECOND; + const ffmpegAvail = ffmpegStatus.available; + const [oversized, setOversized] = useState(false); + const [currentFile, setCurrentFile] = useState(null); + const [currentFileType, setCurrentFileType] = useState(null); + const [optimizeAvail, setOptimizeAvail] = useState(false); + const [userOptimize, setUserOptimize] = usePersistedState('publish-file-user-optimize', false); + const UPLOAD_SIZE_MESSAGE = __( + '%SITE_NAME% uploads are limited to %limit% GB. Download the app for unrestricted publishing.', + { SITE_NAME, limit: TV_PUBLISH_SIZE_LIMIT_GB_STR } + ); const fileSelectorModes = [ { label: __('Choose Replay'), actionName: SOURCE_SELECT, icon: ICONS.MENU }, @@ -106,26 +115,16 @@ function PublishFile(props: Props) { const hasLivestreamData = livestreamData && Boolean(livestreamData.length); const showSourceSelector = isLivestreamClaim && hasLivestreamData; - const ffmpegAvail = ffmpegStatus.available; - const [oversized, setOversized] = useState(false); - const [currentFile, setCurrentFile] = useState(null); - const [currentFileType, setCurrentFileType] = useState(null); - const [optimizeAvail, setOptimizeAvail] = useState(false); - const [userOptimize, setUserOptimize] = usePersistedState('publish-file-user-optimize', false); const [fileSelectSource, setFileSelectSource] = useState( IS_WEB && showSourceSelector ? SOURCE_SELECT : SOURCE_UPLOAD ); // const [showFileUpdate, setShowFileUpdate] = useState(false); const [selectedFileIndex, setSelectedFileIndex] = useState(null); + const PAGE_SIZE = 4; const [currentPage, setCurrentPage] = useState(1); const totalPages = hasLivestreamData && livestreamData.length > PAGE_SIZE ? Math.ceil(livestreamData.length / PAGE_SIZE) : 1; - const UPLOAD_SIZE_MESSAGE = __( - '%SITE_NAME% uploads are limited to %limit% GB. Download the app for unrestricted publishing.', - { SITE_NAME, limit: TV_PUBLISH_SIZE_LIMIT_STR_GB } - ); - // Reset filePath if publish mode changed useEffect(() => { if (mode === PUBLISH_MODES.POST) { @@ -284,7 +283,7 @@ function PublishFile(props: Props) {

{__( 'For video content, use MP4s in H264/AAC format and a friendly bitrate (under 5 Mbps) and resolution (720p) for more reliable streaming. %SITE_NAME% uploads are restricted to %limit% GB.', - { SITE_NAME, limit: TV_PUBLISH_SIZE_LIMIT_STR_GB } + { SITE_NAME, limit: TV_PUBLISH_SIZE_LIMIT_GB_STR } )}{' '}