The swiss army knife of lossless video/audio editing
fix default open action when opening multiple
Mikael Finstad260529b5bc97
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsxindex 240b680c..77cb84f6 100644--- a/src/renderer/src/App.tsx+++ b/src/renderer/src/App.tsx@@ -84,7 +84,7 @@ import {import getSwal, { errorToast, showPlaybackFailedMessage } from './swal';import { adjustRate } from './util/rate-calculator';import { askExtractFramesAsImages } from './dialogs/extractFrames';-import type { CleanupChoicesType } from './dialogs';+import type { CleanupChoicesType, OpenFileResponse } from './dialogs';import { askForOutDir, askForImportChapters, askForFileOpenAction, showDiskFull, showExportFailedDialog, showConcatFailedDialog, openYouTubeChaptersDialog, showRefuseToOverwrite, showOpenDialog, showMuxNotSupported, promptDownloadMediaUrl, showOutputNotWritable, deleteFiles, mustDisallowVob, toastError } from './dialogs';import { openSendReportDialog } from './reporting';import { sortSegments, convertSegmentsToChaptersWithGaps, hasAnySegmentOverlap, isDurationValid, getPlaybackAction, getSegmentTags, filterNonMarkers, isInitialSegment } from './segments';@@ -1843,11 +1843,12 @@ function App() {if (isFileOpened) inputOptions.mergeWithCurrentFile = i18n.t('Merge/concatenate with current file');if (batchFiles.length > 0 || newFilePaths.length > 1) inputOptions.addToBatch = i18n.t('Add the file to the batch list');- const inputOptionsKeys = Object.keys(inputOptions);+ const inputOptionsKeys = Object.keys(inputOptions) as (keyof typeof inputOptions)[];- let openFileResponse: string | undefined;+ let openFileResponse: OpenFileResponse | undefined;if (inputOptionsKeys.length === 1) [openFileResponse] = inputOptionsKeys;- if (enableAskForFileOpenAction && inputOptionsKeys.length > 1) openFileResponse = await askForFileOpenAction(inputOptions);+ if (!enableAskForFileOpenAction && inputOptionsKeys.length > 1) openFileResponse = 'addToBatch';+ if (enableAskForFileOpenAction && inputOptionsKeys.length > 1) openFileResponse = await askForFileOpenAction(Object.entries(inputOptions) as [OpenFileResponse, string][]);else if (newFilePaths.length === 1) openFileResponse = 'open';if (openFileResponse === 'open') {diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsxindex 6ed52351..ee28f627 100644--- a/src/renderer/src/dialogs/index.tsx+++ b/src/renderer/src/dialogs/index.tsx@@ -99,10 +99,12 @@ export async function askForFfPath(defaultPath?: string | undefined) {return (filePaths && filePaths.length === 1) ? filePaths[0] : undefined;}-export async function askForFileOpenAction(inputOptions: Record<string, string>) {- let value: string | undefined;+export type OpenFileResponse = 'open' | 'project' | 'tracks' | 'subtitles' | 'addToBatch' | 'mergeWithCurrentFile';- function onClick(key?: string) {+export async function askForFileOpenAction(inputOptions: [OpenFileResponse, string][]) {+ let value: OpenFileResponse | undefined;++ function onClick(key?: OpenFileResponse) {value = key;getSwal().Swal.close();}@@ -112,7 +114,7 @@ export async function askForFileOpenAction(inputOptions: Record<string, string>)<div style={{ textAlign: 'left' }}><div style={{ marginBottom: '1em' }}>{i18n.t('You opened a new file. What do you want to do?')}</div>- {Object.entries(inputOptions).map(([key, text]) => (+ {inputOptions.map(([key, text]) => (<button type="button" key={key} onClick={() => onClick(key)} className="button-unstyled" style={{ display: 'block', marginBottom: '.5em' }}><FaArrowRight style={{ color: 'var(--gray-10)', verticalAlign: 'middle' }} /> {text}</button>