add Download Folder Chooser

This commit is contained in:
Araxeus
2021-03-26 04:07:45 +03:00
parent cbd7a13275
commit fe8f048571

View File

@ -9,6 +9,8 @@ const ytpl = require("ytpl");
const { sendError } = require("./back");
const { defaultMenuDownloadLabel, getFolder } = require("./utils");
const { setOptions } = require('../../config/plugins')
const { dialog } = require('electron');
let downloadLabel = defaultMenuDownloadLabel;
module.exports = (win, options, refreshMenu) => [
@ -60,4 +62,17 @@ module.exports = (win, options, refreshMenu) => [
});
},
},
{
label: 'Choose download folder:',
click: () => {
let result = dialog.showOpenDialogSync({
properties: ['openDirectory', 'createDirectory'],
defaultPath: Array.isArray(options.downloadFolder) ? options.downloadFolder[0] : undefined,
})
if(result) {
options.downloadFolder = result
setOptions("downloader", options)
} //else = user pressed cancel
}
},
];