From 88fbcc0129f3e360557f70a5d45d115803ec9e7a Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Tue, 9 Apr 2024 14:05:12 +0200 Subject: [PATCH] show title in open dialog #1954 --- src/renderer/src/App.tsx | 12 ++++++------ src/renderer/src/dialogs/index.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 5a470d5d..e4bb11c2 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -107,6 +107,8 @@ hevcPlaybackSupportedPromise.catch((err) => console.error(err)); function App() { + const { t } = useTranslation(); + // Per project state const [commandedTime, setCommandedTime] = useState(0); const [ffmpegCommandLog, setFfmpegCommandLog] = useState([]); @@ -730,7 +732,7 @@ function App() { // Cleanup removed thumbnails useEffect(() => { thumnailsRef.current.forEach((thumbnail) => { - if (!thumbnails.some((t) => t.url === thumbnail.url)) URL.revokeObjectURL(thumbnail.url); + if (!thumbnails.some((nextThumbnail) => nextThumbnail.url === thumbnail.url)) URL.revokeObjectURL(thumbnail.url); }); thumnailsRef.current = thumbnails; }, [thumbnails]); @@ -739,7 +741,7 @@ function App() { const subtitlesByStreamIdRef = useRef({}); useEffect(() => { Object.values(thumnailsRef.current).forEach(({ url }) => { - if (!Object.values(subtitlesByStreamId).some((t) => t.url === url)) URL.revokeObjectURL(url); + if (!Object.values(subtitlesByStreamId).some((existingThumbnail) => existingThumbnail.url === url)) URL.revokeObjectURL(url); }); subtitlesByStreamIdRef.current = subtitlesByStreamId; }, [subtitlesByStreamId]); @@ -1992,10 +1994,10 @@ function App() { }, [alwaysConcatMultipleFiles, batchLoadPaths, setWorking, isFileOpened, batchFiles.length, userOpenSingleFile, checkFileOpened, loadEdlFile, enableAskForFileOpenAction, addStreamSourceFile, filePath]); const openFilesDialog = useCallback(async () => { - const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile', 'openDirectory', 'multiSelections'], defaultPath: lastOpenedPathRef.current }); + const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile', 'openDirectory', 'multiSelections'], defaultPath: lastOpenedPathRef.current!, title: t('Open file') }); if (canceled) return; userOpenFiles(filePaths); - }, [userOpenFiles]); + }, [t, userOpenFiles]); const concatBatch = useCallback(() => { if (batchFiles.length < 2) { @@ -2455,8 +2457,6 @@ function App() { const thumbnailsSorted = useMemo(() => sortBy(thumbnails, (thumbnail) => thumbnail.time), [thumbnails]); - const { t } = useTranslation(); - function renderSubtitles() { if (!activeSubtitle) return null; return ; diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsx index 3c7c01a9..a6a631eb 100644 --- a/src/renderer/src/dialogs/index.tsx +++ b/src/renderer/src/dialogs/index.tsx @@ -46,7 +46,7 @@ export const showOpenDialog = async ({ filters = isWindows ? [{ name: i18n.t('All Files'), extensions: ['*'] }] : undefined, ...props // @ts-expect-error todo -}) => dialog.showOpenDialog({ ...props, filters }); +}: Parameters[0]) => dialog.showOpenDialog({ ...props, filters }); export async function askForYouTubeInput() { const example = i18n.t('YouTube video description\n00:00 Intro\n00:01 Chapter 2\n00:00:02.123 Chapter 3'); @@ -73,7 +73,7 @@ export async function askForYouTubeInput() { export async function askForInputDir(defaultPath?: string | undefined) { const { filePaths } = await showOpenDialog({ properties: ['openDirectory', 'createDirectory'], - defaultPath, + defaultPath: defaultPath!, title: i18n.t('Please confirm folder'), message: i18n.t('Press confirm to grant LosslessCut access to write the project file (due to App Sandbox restrictions).'), buttonLabel: i18n.t('Confirm'), @@ -84,7 +84,7 @@ export async function askForInputDir(defaultPath?: string | undefined) { export async function askForOutDir(defaultPath?: string | undefined) { const { filePaths } = await showOpenDialog({ properties: ['openDirectory', 'createDirectory'], - defaultPath, + defaultPath: defaultPath!, title: i18n.t('Where do you want to save output files?'), message: i18n.t('Where do you want to save output files? Make sure there is enough free space in this folder'), buttonLabel: i18n.t('Select output folder'), @@ -95,7 +95,7 @@ export async function askForOutDir(defaultPath?: string | undefined) { export async function askForFfPath(defaultPath?: string | undefined) { const { filePaths } = await showOpenDialog({ properties: ['openDirectory'], - defaultPath, + defaultPath: defaultPath!, title: i18n.t('Select custom FFmpeg directory'), }); return (filePaths && filePaths.length === 1) ? filePaths[0] : undefined;