Add option to hide certain notifications #467

pull/523/head
Mikael Finstad 6 years ago
parent ef1ae63343
commit 267225996e

@ -19,6 +19,7 @@ const defaults = {
ffmpegExperimental: false, ffmpegExperimental: false,
preserveMovData: false, preserveMovData: false,
avoidNegativeTs: 'make_zero', avoidNegativeTs: 'make_zero',
hideNotifications: undefined,
}, },
}; };

@ -192,6 +192,8 @@ const App = memo(() => {
useEffect(() => safeSetConfig('language', language), [language]); useEffect(() => safeSetConfig('language', language), [language]);
const [ffmpegExperimental, setFfmpegExperimental] = useState(configStore.get('ffmpegExperimental')); const [ffmpegExperimental, setFfmpegExperimental] = useState(configStore.get('ffmpegExperimental'));
useEffect(() => safeSetConfig('ffmpegExperimental', ffmpegExperimental), [ffmpegExperimental]); useEffect(() => safeSetConfig('ffmpegExperimental', ffmpegExperimental), [ffmpegExperimental]);
const [hideNotifications, setHideNotifications] = useState(configStore.get('hideNotifications'));
useEffect(() => safeSetConfig('hideNotifications', hideNotifications), [hideNotifications]);
useEffect(() => { useEffect(() => {
i18n.changeLanguage(language || fallbackLng).catch(console.error); i18n.changeLanguage(language || fallbackLng).catch(console.error);
@ -255,12 +257,14 @@ const App = memo(() => {
setCopyStreamIdsForPath(path, (old) => ({ ...old, [index]: !old[index] })); setCopyStreamIdsForPath(path, (old) => ({ ...old, [index]: !old[index] }));
}, []); }, []);
function toggleMute() { const hideAllNotifications = hideNotifications === 'all';
const toggleMute = useCallback(() => {
setMuted((v) => { setMuted((v) => {
if (!v) toast.fire({ icon: 'info', title: i18n.t('Muted preview (exported file will not be affected)') }); if (!v && !hideAllNotifications) toast.fire({ icon: 'info', title: i18n.t('Muted preview (exported file will not be affected)') });
return !v; return !v;
}); });
} }, [hideAllNotifications]);
const seekAbs = useCallback((val) => { const seekAbs = useCallback((val) => {
const video = videoRef.current; const video = videoRef.current;
@ -626,14 +630,16 @@ const App = memo(() => {
}, [assureOutDirAccess, outputDir, ffmpegExperimental, preserveMovData]); }, [assureOutDirAccess, outputDir, ffmpegExperimental, preserveMovData]);
const toggleCaptureFormat = useCallback(() => setCaptureFormat(f => (f === 'png' ? 'jpeg' : 'png')), []); const toggleCaptureFormat = useCallback(() => setCaptureFormat(f => (f === 'png' ? 'jpeg' : 'png')), []);
const toggleKeyframeCut = useCallback((showMessage) => setKeyframeCut((val) => { const toggleKeyframeCut = useCallback((showMessage) => setKeyframeCut((val) => {
const newVal = !val; const newVal = !val;
if (showMessage) { if (showMessage && !hideAllNotifications) {
if (newVal) toast.fire({ title: i18n.t('Keyframe cut enabled'), text: i18n.t('Will now cut at the nearest keyframe before the desired start cutpoint. This is recommended for most files.') }); if (newVal) toast.fire({ title: i18n.t('Keyframe cut enabled'), text: i18n.t('Will now cut at the nearest keyframe before the desired start cutpoint. This is recommended for most files.') });
else toast.fire({ title: i18n.t('Keyframe cut disabled'), text: i18n.t('Will now cut at the exact position, but may leave an empty portion at the beginning of the file. You may have to set the cutpoint a few frames before the next keyframe to achieve a precise cut'), timer: 7000 }); else toast.fire({ title: i18n.t('Keyframe cut disabled'), text: i18n.t('Will now cut at the exact position, but may leave an empty portion at the beginning of the file. You may have to set the cutpoint a few frames before the next keyframe to achieve a precise cut'), timer: 7000 });
} }
return newVal; return newVal;
}), []); }), [hideAllNotifications]);
const toggleAutoMerge = useCallback(() => setAutoMerge(val => !val), []); const toggleAutoMerge = useCallback(() => setAutoMerge(val => !val), []);
const togglePreserveMovData = useCallback(() => setPreserveMovData((val) => !val), []); const togglePreserveMovData = useCallback(() => setPreserveMovData((val) => !val), []);
@ -819,9 +825,9 @@ const App = memo(() => {
// Cleanup old // Cleanup old
useEffect(() => () => waveform && URL.revokeObjectURL(waveform.url), [waveform]); useEffect(() => () => waveform && URL.revokeObjectURL(waveform.url), [waveform]);
function showUnsupportedFileMessage() { const showUnsupportedFileMessage = useCallback(() => {
toast.fire({ timer: 13000, text: i18n.t('File not natively supported. Preview may have no audio or low quality. The final export will however be lossless with audio. You may convert it from the menu for a better preview with audio.') }); if (!hideAllNotifications) toast.fire({ timer: 13000, text: i18n.t('File not natively supported. Preview may have no audio or low quality. The final export will however be lossless with audio. You may convert it from the menu for a better preview with audio.') });
} }, [hideAllNotifications]);
const createDummyVideo = useCallback(async (cod, fp) => { const createDummyVideo = useCallback(async (cod, fp) => {
const html5ifiedDummyPathDummy = getOutPath(cod, fp, 'html5ified-dummy.mkv'); const html5ifiedDummyPathDummy = getOutPath(cod, fp, 'html5ified-dummy.mkv');
@ -834,7 +840,7 @@ const App = memo(() => {
setDummyVideoPath(html5ifiedDummyPathDummy); setDummyVideoPath(html5ifiedDummyPathDummy);
setHtml5FriendlyPath(); setHtml5FriendlyPath();
showUnsupportedFileMessage(); showUnsupportedFileMessage();
}, []); }, [showUnsupportedFileMessage]);
const showPlaybackFailedMessage = () => errorToast(i18n.t('Unable to playback this file. Try to convert to supported format from the menu')); const showPlaybackFailedMessage = () => errorToast(i18n.t('Unable to playback this file. Try to convert to supported format from the menu'));
@ -1077,7 +1083,7 @@ const App = memo(() => {
const changePlaybackRate = useCallback((dir) => { const changePlaybackRate = useCallback((dir) => {
if (canvasPlayerEnabled) { if (canvasPlayerEnabled) {
toast.fire({ title: i18n.t('Unable to playback rate right now'), timer: 1000 }); toast.fire({ title: i18n.t('Unable to change playback rate right now'), timer: 1000 });
return; return;
} }
@ -1258,7 +1264,7 @@ const App = memo(() => {
} finally { } finally {
setWorking(); setWorking();
} }
}, [resetState, working, createDummyVideo, loadEdlFile, getEdlFilePath, getHtml5ifiedPath, loadCutSegments, enableAskForImportChapters]); }, [resetState, working, createDummyVideo, loadEdlFile, getEdlFilePath, getHtml5ifiedPath, loadCutSegments, enableAskForImportChapters, showUnsupportedFileMessage]);
const toggleHelp = useCallback(() => setHelpVisible(val => !val), []); const toggleHelp = useCallback(() => setHelpVisible(val => !val), []);
const toggleSettings = useCallback(() => setSettingsVisible(val => !val), []); const toggleSettings = useCallback(() => setSettingsVisible(val => !val), []);
@ -1544,14 +1550,14 @@ const App = memo(() => {
if (error.code === MEDIA_ERR_SRC_NOT_SUPPORTED && !dummyVideoPath) { if (error.code === MEDIA_ERR_SRC_NOT_SUPPORTED && !dummyVideoPath) {
console.log('MEDIA_ERR_SRC_NOT_SUPPORTED - trying to create dummy'); console.log('MEDIA_ERR_SRC_NOT_SUPPORTED - trying to create dummy');
toast.fire({ icon: 'info', text: 'This file is not natively supported. Creating a preview file...' }); if (!hideAllNotifications) toast.fire({ icon: 'info', text: 'This file is not natively supported. Creating a preview file...' });
if (hasVideo) { if (hasVideo) {
await tryCreateDummyVideo(); await tryCreateDummyVideo();
} else if (hasAudio) { } else if (hasAudio) {
await html5ifyAndLoad('fastest-audio'); await html5ifyAndLoad('fastest-audio');
} }
} }
}, [tryCreateDummyVideo, fileUri, dummyVideoPath, hasVideo, hasAudio, html5ifyAndLoad]); }, [tryCreateDummyVideo, fileUri, dummyVideoPath, hasVideo, hasAudio, html5ifyAndLoad, hideAllNotifications]);
useEffect(() => { useEffect(() => {
function fileOpened(event, filePaths) { function fileOpened(event, filePaths) {
@ -1855,12 +1861,14 @@ const App = memo(() => {
setInvertTimelineScroll={setInvertTimelineScroll} setInvertTimelineScroll={setInvertTimelineScroll}
language={language} language={language}
setLanguage={setLanguage} setLanguage={setLanguage}
hideNotifications={hideNotifications}
setHideNotifications={setHideNotifications}
AutoExportToggler={AutoExportToggler} AutoExportToggler={AutoExportToggler}
renderCaptureFormatButton={renderCaptureFormatButton} renderCaptureFormatButton={renderCaptureFormatButton}
onWheelTunerRequested={onWheelTunerRequested} onWheelTunerRequested={onWheelTunerRequested}
/> />
), [AutoExportToggler, askBeforeClose, autoMerge, autoSaveProjectFile, customOutDir, invertCutSegments, keyframeCut, renderCaptureFormatButton, timecodeShowFrames, changeOutDir, onWheelTunerRequested, language, invertTimelineScroll, ffmpegExperimental, setFfmpegExperimental, enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction]); ), [AutoExportToggler, askBeforeClose, autoMerge, autoSaveProjectFile, customOutDir, invertCutSegments, keyframeCut, renderCaptureFormatButton, timecodeShowFrames, changeOutDir, onWheelTunerRequested, language, invertTimelineScroll, ffmpegExperimental, setFfmpegExperimental, enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction, hideNotifications, setHideNotifications]);
useEffect(() => { useEffect(() => {
if (!isStoreBuild) loadMifiLink().then(setMifiLink); if (!isStoreBuild) loadMifiLink().then(setMifiLink);

@ -9,6 +9,7 @@ const Settings = memo(({
AutoExportToggler, renderCaptureFormatButton, onWheelTunerRequested, language, setLanguage, AutoExportToggler, renderCaptureFormatButton, onWheelTunerRequested, language, setLanguage,
invertTimelineScroll, setInvertTimelineScroll, ffmpegExperimental, setFfmpegExperimental, invertTimelineScroll, setInvertTimelineScroll, ffmpegExperimental, setFfmpegExperimental,
enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction, enableAskForImportChapters, setEnableAskForImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction,
hideNotifications, setHideNotifications,
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -196,6 +197,17 @@ const Settings = memo(({
</Table.TextCell> </Table.TextCell>
</Row> </Row>
<Row>
<KeyCell>{t('Hide informational notifications?')}</KeyCell>
<Table.TextCell>
<Checkbox
label={t('Check to hide notifications')}
checked={!!hideNotifications}
onChange={e => setHideNotifications(e.target.checked ? 'all' : undefined)}
/>
</Table.TextCell>
</Row>
<Row> <Row>
<KeyCell>{t('Ask about what to do when opening a new file when another file is already already open?')}</KeyCell> <KeyCell>{t('Ask about what to do when opening a new file when another file is already already open?')}</KeyCell>
<Table.TextCell> <Table.TextCell>

Loading…
Cancel
Save