fix open URL on MAS

pull/2133/head
Mikael Finstad 2 years ago
parent 36fb4dbc50
commit 1c320f423d
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -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…
Cancel
Save