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:
parent
36fb4dbc50
commit
1c320f423d
@ -2181,21 +2181,23 @@ function App() {
|
||||
}, [currentSegIndexSafe, onEditSegmentTags]);
|
||||
|
||||
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 {
|
||||
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);
|
||||
if (downloaded) await loadMedia({ filePath: outPath });
|
||||
} catch (err) {
|
||||
if (err instanceof DirectoryAccessDeclinedError) return;
|
||||
handleError(err);
|
||||
} finally {
|
||||
setWorking();
|
||||
}
|
||||
}, [customOutDir, loadMedia, setWorking]);
|
||||
}, [customOutDir, ensureWritableOutDir, loadMedia, setWorking, t]);
|
||||
|
||||
type MainKeyboardAction = Exclude<KeyboardAction, 'closeActiveScreen' | 'toggleKeyboardShortcuts' | 'goToTimecodeDirect'>;
|
||||
|
||||
|
@ -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.
|
||||
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;
|
||||
|
||||
const effectiveOutDirPath = getOutDir(newCustomOutDir, inputPath);
|
||||
|
Loading…
Reference in New Issue
Block a user