1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-19 19:05:56 +01:00
upscayl/electron/commands/select-folder.ts

22 lines
592 B
TypeScript
Raw Normal View History

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;