WIP CCC Part Price Change.

This commit is contained in:
Patrick Fic
2025-04-02 17:10:16 -07:00
parent da18d3308f
commit b60d9b0f41
13 changed files with 526 additions and 49 deletions

View File

@@ -1,7 +1,8 @@
import { BrowserWindow, dialog, IpcMainInvokeEvent } from "electron";
import { dialog, IpcMainInvokeEvent } from "electron";
import log from "electron-log/main";
import _ from "lodash";
import Store from "../store/store";
import { getMainWindow } from "../util/toRenderer";
import {
addWatcherPath,
removeWatcherPath,
@@ -10,7 +11,7 @@ import {
} from "../watcher/watcher";
const SettingsWatchedFilePathsAdd = async (): Promise<string[]> => {
const mainWindow = BrowserWindow.getAllWindows()[0]; //TODO: Filter to only main window once a proper key has been set.
const mainWindow = getMainWindow();
if (!mainWindow) {
log.error("No main window found when trying to open dialog");
return [];
@@ -74,8 +75,30 @@ const SettingsWatcherPollingSet = async (
return { enabled, interval };
};
const SettingsPpcFilPathGet = async (): Promise<string> => {
const ppcFilePath: string = Store.get("settings.ppcFilePath");
return ppcFilePath;
};
const SettingsPpcFilPathSet = async (): Promise<string> => {
const mainWindow = getMainWindow();
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.ppcFilePath", result.filePaths[0]); //There should only ever be on directory that was selected.
}
return (Store.get("settings.ppcFilePath") as string) || "";
};
export {
SettingsPpcFilPathGet,
SettingsPpcFilPathSet,
SettingsWatchedFilePathsAdd,
SettingsWatchedFilePathsGet,
SettingsWatchedFilePathsRemove,