From 79dcddc6043bfec6720ab34d1295c841c9143754 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 30 Nov 2020 00:06:06 +0100 Subject: [PATCH] Allow turn off export confirm dialog #512 --- public/configStore.js | 1 + src/App.jsx | 41 +++++++++++++++----------- src/ExportConfirm.jsx | 13 +++++--- src/RightMenu.jsx | 9 ++++-- src/components/ToggleExportConfirm.jsx | 17 +++++++++++ 5 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 src/components/ToggleExportConfirm.jsx diff --git a/public/configStore.js b/public/configStore.js index d540dd5..6db93af 100644 --- a/public/configStore.js +++ b/public/configStore.js @@ -10,6 +10,7 @@ const defaults = { timecodeShowFrames: false, invertCutSegments: false, autoExportExtraStreams: true, + exportConfirmEnabled: true, askBeforeClose: false, enableAskForImportChapters: true, enableAskForFileOpenAction: true, diff --git a/src/App.jsx b/src/App.jsx index 9a20560..cb762a9 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -198,6 +198,8 @@ const App = memo(() => { useEffect(() => safeSetConfig('autoLoadTimecode', autoLoadTimecode), [autoLoadTimecode]); const [autoDeleteMergedSegments, setAutoDeleteMergedSegments] = useState(configStore.get('autoDeleteMergedSegments')); useEffect(() => safeSetConfig('autoDeleteMergedSegments', autoDeleteMergedSegments), [autoDeleteMergedSegments]); + const [exportConfirmEnabled, setExportConfirmEnabled] = useState(configStore.get('exportConfirmEnabled')); + useEffect(() => safeSetConfig('exportConfirmEnabled', exportConfirmEnabled), [exportConfirmEnabled]); useEffect(() => { i18n.changeLanguage(language || fallbackLng).catch(console.error); @@ -232,6 +234,8 @@ const App = memo(() => { } } + const toggleExportConfirmEnabled = useCallback(() => setExportConfirmEnabled((v) => !v), []); + const toggleKeyframesEnabled = useCallback(() => { setKeyframesEnabled((old) => { const enabled = !old; @@ -968,22 +972,6 @@ const App = memo(() => { } }, [openSendReportDialogWithState, detectedFileFormat]); - const onExportPress = useCallback(async () => { - if (working || !filePath) return; - - if (haveInvalidSegs) { - errorToast(i18n.t('Start time must be before end time')); - return; - } - - if (!outSegments || outSegments.length < 1) { - errorToast(i18n.t('No segments to export')); - return; - } - - setExportConfirmVisible(true); - }, [working, filePath, haveInvalidSegs, outSegments]); - const closeExportConfirm = useCallback(() => setExportConfirmVisible(false), []); const onExportConfirm = useCallback(async ({ exportSingle } = {}) => { @@ -1066,6 +1054,23 @@ const App = memo(() => { } }, [autoMerge, copyFileStreams, customOutDir, duration, effectiveRotation, exportExtraStreams, ffmpegExperimental, fileFormat, fileFormatData, filePath, handleCutFailed, isCustomFormatSelected, isRotationSet, keyframeCut, mainStreams, nonCopiedExtraStreams, outSegments, outputDir, shortestFlag, working, preserveMovData, avoidNegativeTs, numStreamsToCopy, hideAllNotifications, currentSegIndexSafe, autoDeleteMergedSegments]); + const onExportPress = useCallback(async () => { + if (working || !filePath) return; + + if (haveInvalidSegs) { + errorToast(i18n.t('Start time must be before end time')); + return; + } + + if (!outSegments || outSegments.length < 1) { + errorToast(i18n.t('No segments to export')); + return; + } + + if (exportConfirmEnabled) setExportConfirmVisible(true); + else await onExportConfirm(); + }, [working, filePath, haveInvalidSegs, outSegments, exportConfirmEnabled, onExportConfirm]); + const capture = useCallback(async () => { if (!filePath || !isDurationValid(duration)) return; @@ -2213,11 +2218,13 @@ const App = memo(() => { capture={capture} onExportPress={onExportPress} outSegments={outSegments} + exportConfirmEnabled={exportConfirmEnabled} + toggleExportConfirmEnabled={toggleExportConfirmEnabled} /> - + { const { t } = useTranslation(); @@ -131,16 +133,19 @@ const ExportConfirm = memo(({
+ +
{t('Show summary before exporting?')}
+ {outSegments.length > 1 && !invertCutSegments && (
onExportConfirm({ exportSingle: true })} style={{ cursor: 'pointer', background: primaryColor, borderRadius: 5, padding: '3px 10px', fontSize: 13, marginRight: 10 }}> diff --git a/src/RightMenu.jsx b/src/RightMenu.jsx index ae73033..e2bf542 100644 --- a/src/RightMenu.jsx +++ b/src/RightMenu.jsx @@ -4,12 +4,15 @@ import { FaTrashAlt } from 'react-icons/fa'; import { MdRotate90DegreesCcw } from 'react-icons/md'; import { useTranslation } from 'react-i18next'; +import { primaryTextColor } from './colors'; + import ExportButton from './components/ExportButton'; +import ToggleExportConfirm from './components/ToggleExportConfirm'; const RightMenu = memo(({ isRotationSet, rotation, areWeCutting, increaseRotation, deleteSource, renderCaptureFormatButton, - capture, onExportPress, outSegments, hasVideo, autoMerge, + capture, onExportPress, outSegments, hasVideo, autoMerge, exportConfirmEnabled, toggleExportConfirmEnabled, }) => { const rotationStr = `${rotation}°`; @@ -22,7 +25,7 @@ const RightMenu = memo(({ {isRotationSet && rotationStr} )} + +
); diff --git a/src/components/ToggleExportConfirm.jsx b/src/components/ToggleExportConfirm.jsx new file mode 100644 index 0000000..708a4b6 --- /dev/null +++ b/src/components/ToggleExportConfirm.jsx @@ -0,0 +1,17 @@ +import React, { memo } from 'react'; +import { useTranslation } from 'react-i18next'; + +import { MdEventNote } from 'react-icons/md'; + +import { primaryTextColor } from '../colors'; + + +const ToggleExportConfirm = memo(({ exportConfirmEnabled, toggleExportConfirmEnabled, size = 23, style }) => { + const { t } = useTranslation(); + + return ( + + ); +}); + +export default ToggleExportConfirm;