1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-21 18:02:35 +01:00

fix open URL on MAS

This commit is contained in:
Mikael Finstad 2024-08-16 22:08:43 +02:00
parent 36fb4dbc50
commit 1c320f423d
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
2 changed files with 11 additions and 8 deletions

View File

@ -2181,21 +2181,23 @@ function App() {
}, [currentSegIndexSafe, onEditSegmentTags]); }, [currentSegIndexSafe, onEditSegmentTags]);
const promptDownloadMediaUrlWrapper = useCallback(async () => { const promptDownloadMediaUrlWrapper = useCallback(async () => {
if (customOutDir == null) {
errorToast(i18n.t('Please select a working directory first'));
return;
}
const outPath = getDownloadMediaOutPath(customOutDir, `downloaded-media-${Date.now()}.mkv`);
try { try {
setWorking(true); setWorking({ text: t('Downloading URL') });
const newCustomOutDir = await ensureWritableOutDir({ outDir: customOutDir });
if (newCustomOutDir == null) {
errorToast(i18n.t('Please select a working directory first'));
return;
}
const outPath = getDownloadMediaOutPath(newCustomOutDir, `downloaded-media-${Date.now()}.mkv`);
const downloaded = await promptDownloadMediaUrl(outPath); const downloaded = await promptDownloadMediaUrl(outPath);
if (downloaded) await loadMedia({ filePath: outPath }); if (downloaded) await loadMedia({ filePath: outPath });
} catch (err) { } catch (err) {
if (err instanceof DirectoryAccessDeclinedError) return;
handleError(err); handleError(err);
} finally { } finally {
setWorking(); setWorking();
} }
}, [customOutDir, loadMedia, setWorking]); }, [customOutDir, ensureWritableOutDir, loadMedia, setWorking, t]);
type MainKeyboardAction = Exclude<KeyboardAction, 'closeActiveScreen' | 'toggleKeyboardShortcuts' | 'goToTimecodeDirect'>; type MainKeyboardAction = Exclude<KeyboardAction, 'closeActiveScreen' | 'toggleKeyboardShortcuts' | 'goToTimecodeDirect'>;

View File

@ -56,7 +56,7 @@ export default ({ setCustomOutDir }: { setCustomOutDir: (a: string | undefined)
} }
}, []); }, []);
const ensureWritableOutDir = useCallback(async ({ inputPath, outDir }: { inputPath: string | undefined, outDir: string | undefined }) => { const ensureWritableOutDir = useCallback(async ({ inputPath, outDir }: { inputPath?: string | undefined, outDir: string | undefined }) => {
// we might need to change the output directory if the user chooses to give us a different one. // we might need to change the output directory if the user chooses to give us a different one.
let newCustomOutDir = outDir; let newCustomOutDir = outDir;
@ -69,6 +69,7 @@ export default ({ setCustomOutDir }: { setCustomOutDir: (a: string | undefined)
} }
} }
// if we don't (no longer) have a working dir, and not an main file path, then there's nothing we can do, just return the dir
if (!newCustomOutDir && !inputPath) return newCustomOutDir; if (!newCustomOutDir && !inputPath) return newCustomOutDir;
const effectiveOutDirPath = getOutDir(newCustomOutDir, inputPath); const effectiveOutDirPath = getOutDir(newCustomOutDir, inputPath);