2023-09-10 11:14:04 +02:00
|
|
|
import { dialog } from "electron";
|
2023-09-10 19:42:18 +02:00
|
|
|
import { folderPath, setFolderPath } from "../utils/config-variables";
|
2023-09-10 11:14:04 +02:00
|
|
|
import logit from "../utils/logit";
|
|
|
|
|
|
|
|
const selectFolder = async (event, message) => {
|
|
|
|
const { canceled, filePaths: folderPaths } = await dialog.showOpenDialog({
|
|
|
|
properties: ["openDirectory"],
|
2023-09-10 19:42:18 +02:00
|
|
|
defaultPath: folderPath,
|
2023-09-10 11:14:04 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (canceled) {
|
|
|
|
logit("🚫 Select Folder Operation Cancelled");
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
setFolderPath(folderPaths[0]);
|
2023-09-10 19:42:18 +02:00
|
|
|
logit("📁 Selected Folder Path: ", folderPath);
|
2023-09-10 11:14:04 +02:00
|
|
|
return folderPaths[0];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default selectFolder;
|