Skip to content

Commit

Permalink
Merge pull request #77 from vlad-s/fix/multiple-downloads-always-prom…
Browse files Browse the repository at this point in the history
…pt-path

Fixed download prompt triggering on multiple items
  • Loading branch information
Inrixia authored Sep 6, 2024
2 parents 5e59952 + e20d8ad commit c13d176
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/SongDownloader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ ContextMenu.onOpen(async (contextSource, contextMenu, trackItems) => {
updateMethods.prep();
for (const trackItem of trackItems) {
if (trackItem.id === undefined) continue;
await downloadTrack(trackItem, updateMethods, folderPath).catch(trace.msg.err.withContext("Error downloading track"));
await downloadTrack(trackItem, updateMethods, folderPath, trackItems.length > 1).catch(trace.msg.err.withContext("Error downloading track"));
}
updateMethods.clear();
});
});

const downloadTrack = async (trackItem: TrackItem, updateMethods: ButtonMethods, folderPath?: string) => {
const downloadTrack = async (trackItem: TrackItem, updateMethods: ButtonMethods, folderPath?: string, noTriggerDialog: boolean = false) => {
let trackId = trackItem.id!;
if (settings.useRealMAX && settings.desiredDownloadQuality === AudioQuality.HiRes) {
updateMethods.set("Checking RealMAX for better quality...");
Expand All @@ -115,7 +115,7 @@ const downloadTrack = async (trackItem: TrackItem, updateMethods: ButtonMethods,
const pathInfo = parseFileName(await metaTags, await playbackInfo);

pathInfo.basePath = folderPath;
if (folderPath === undefined || !settings.alwaysUseDefaultPath) {
if ((folderPath === undefined || !settings.alwaysUseDefaultPath) && !noTriggerDialog) {
updateMethods.set("Prompting for download path...");
const fileName = pathInfo.fileName;
const dialogResult = await saveDialog({ defaultPath: `${folderPath ?? ""}${pathSeparator}${fileName}`, filters: [{ name: "", extensions: [fileName ?? "*"] }] });
Expand Down

0 comments on commit c13d176

Please sign in to comment.