Minor renaming for clarity. No functional change.
updateOptimizeState --> updateFileInfo available --> ffmpegAvail
This commit is contained in:
parent
406ca3b998
commit
0fcf78a700
1 changed files with 12 additions and 12 deletions
|
@ -45,7 +45,7 @@ function PublishFile(props: Props) {
|
||||||
isVid,
|
isVid,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const { available } = ffmpegStatus;
|
const ffmpegAvail = ffmpegStatus.available;
|
||||||
const [oversized, setOversized] = useState(false);
|
const [oversized, setOversized] = useState(false);
|
||||||
const [currentFile, setCurrentFile] = useState(null);
|
const [currentFile, setCurrentFile] = useState(null);
|
||||||
|
|
||||||
|
@ -64,16 +64,16 @@ function PublishFile(props: Props) {
|
||||||
if (!filePath || filePath === '') {
|
if (!filePath || filePath === '') {
|
||||||
setCurrentFile('');
|
setCurrentFile('');
|
||||||
setOversized(false);
|
setOversized(false);
|
||||||
updateOptimizeState(0, 0, false);
|
updateFileInfo(0, 0, false);
|
||||||
} else if (typeof filePath !== 'string') {
|
} else if (typeof filePath !== 'string') {
|
||||||
// Update currentFile file
|
// Update currentFile file
|
||||||
if (filePath.name !== currentFile && filePath.path !== currentFile) {
|
if (filePath.name !== currentFile && filePath.path !== currentFile) {
|
||||||
handleFileChange(filePath);
|
handleFileChange(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [filePath, currentFile, handleFileChange, updateOptimizeState]);
|
}, [filePath, currentFile, handleFileChange, updateFileInfo]);
|
||||||
|
|
||||||
function updateOptimizeState(duration, size, isvid) {
|
function updateFileInfo(duration, size, isvid) {
|
||||||
updatePublishForm({ fileDur: duration, fileSize: size, fileVid: isvid });
|
updatePublishForm({ fileDur: duration, fileSize: size, fileVid: isvid });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ function PublishFile(props: Props) {
|
||||||
function getUnitsForMB(s) {
|
function getUnitsForMB(s) {
|
||||||
if (s < MINUTES_THRESHOLD) {
|
if (s < MINUTES_THRESHOLD) {
|
||||||
if (secondsToProcess > 1) return __('seconds');
|
if (secondsToProcess > 1) return __('seconds');
|
||||||
return __('second');
|
return __('second');
|
||||||
} else if (s >= MINUTES_THRESHOLD && s < HOURS_THRESHOLD) {
|
} else if (s >= MINUTES_THRESHOLD && s < HOURS_THRESHOLD) {
|
||||||
if (Math.floor(secondsToProcess / 60) > 1) return __('minutes');
|
if (Math.floor(secondsToProcess / 60) > 1) return __('minutes');
|
||||||
return __('minute');
|
return __('minute');
|
||||||
|
@ -195,15 +195,15 @@ function PublishFile(props: Props) {
|
||||||
const video = document.createElement('video');
|
const video = document.createElement('video');
|
||||||
video.preload = 'metadata';
|
video.preload = 'metadata';
|
||||||
video.onloadedmetadata = function() {
|
video.onloadedmetadata = function() {
|
||||||
updateOptimizeState(video.duration, file.size, isVideo);
|
updateFileInfo(video.duration, file.size, isVideo);
|
||||||
window.URL.revokeObjectURL(video.src);
|
window.URL.revokeObjectURL(video.src);
|
||||||
};
|
};
|
||||||
video.onerror = function() {
|
video.onerror = function() {
|
||||||
updateOptimizeState(0, file.size, isVideo);
|
updateFileInfo(0, file.size, isVideo);
|
||||||
};
|
};
|
||||||
video.src = window.URL.createObjectURL(file);
|
video.src = window.URL.createObjectURL(file);
|
||||||
} else {
|
} else {
|
||||||
updateOptimizeState(0, file.size, isVideo);
|
updateFileInfo(0, file.size, isVideo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,13 +266,13 @@ function PublishFile(props: Props) {
|
||||||
{/* @if TARGET='app' */}
|
{/* @if TARGET='app' */}
|
||||||
<FormField
|
<FormField
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={isVid && available && optimize}
|
checked={isVid && ffmpegAvail && optimize}
|
||||||
disabled={!isVid || !available}
|
disabled={!isVid || !ffmpegAvail}
|
||||||
onChange={e => updatePublishForm({ optimize: e.target.checked })}
|
onChange={e => updatePublishForm({ optimize: e.target.checked })}
|
||||||
label={__('Optimize and transcode video')}
|
label={__('Optimize and transcode video')}
|
||||||
name="optimize"
|
name="optimize"
|
||||||
/>
|
/>
|
||||||
{!available && (
|
{!ffmpegAvail && (
|
||||||
<p className="help">
|
<p className="help">
|
||||||
<I18nMessage
|
<I18nMessage
|
||||||
tokens={{
|
tokens={{
|
||||||
|
@ -283,7 +283,7 @@ function PublishFile(props: Props) {
|
||||||
</I18nMessage>
|
</I18nMessage>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{Boolean(size) && available && optimize && isVid && (
|
{Boolean(size) && ffmpegAvail && optimize && isVid && (
|
||||||
<p className="help">
|
<p className="help">
|
||||||
<I18nMessage
|
<I18nMessage
|
||||||
tokens={{
|
tokens={{
|
||||||
|
|
Loading…
Add table
Reference in a new issue