Basic storage of watched paths.

This commit is contained in:
Patrick Fic
2025-03-12 15:31:35 -07:00
parent fb991670fe
commit a01d4bfb44
9 changed files with 131 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
import { BrowserWindow, dialog, IpcMainInvokeEvent } from "electron";
import log from "electron-log/main";
import _ from "lodash";
import Store from "../store/store";
const SettingsWatchedFilePathsAdd = async (event: IpcMainInvokeEvent) => {
const mainWindow = BrowserWindow.getAllWindows()[0]; //TODO: Filter to only main window once a proper key has been set.
if (!mainWindow) {
log.error("No main window found when trying to open dialog");
return;
}
const result = await dialog.showOpenDialog(mainWindow, {
properties: ["openDirectory"],
});
if (!result.canceled) {
Store.set(
"settings.filepaths",
_.union(result.filePaths, Store.get("filepaths"))
);
}
return Store.get("settings.filepaths");
};
const SettingsWatchedFilePathsGet = async (event: IpcMainInvokeEvent) => {
const filepaths = Store.get("settings.filepaths");
return filepaths;
};
export { SettingsWatchedFilePathsAdd, SettingsWatchedFilePathsGet };