Refactor PPC to pull out reusable componenets.
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
||||
SettingsWatchedFilePathsRemove,
|
||||
SettingsWatcherPollingGet,
|
||||
SettingsWatcherPollingSet,
|
||||
SettingEmsOutFilPathSet,
|
||||
SettingEmsOutFilPathGet,
|
||||
} from "./ipcMainHandler.settings";
|
||||
import {
|
||||
ipcMainHandleAuthStateChanged,
|
||||
@@ -98,6 +100,14 @@ ipcMain.handle(
|
||||
|
||||
ipcMain.handle(ipcTypes.toMain.settings.getPpcFilePath, SettingsPpcFilPathGet);
|
||||
ipcMain.handle(ipcTypes.toMain.settings.setPpcFilePath, SettingsPpcFilPathSet);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.getEmsOutFilePath,
|
||||
SettingEmsOutFilPathGet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.setEmsOutFilePath,
|
||||
SettingEmsOutFilPathSet,
|
||||
);
|
||||
|
||||
ipcMain.handle(ipcTypes.toMain.user.getActiveShop, () => {
|
||||
return store.get("app.bodyshop.shopname");
|
||||
|
||||
@@ -96,6 +96,27 @@ const SettingsPpcFilPathSet = async (): Promise<string> => {
|
||||
return (Store.get("settings.ppcFilePath") as string) || "";
|
||||
};
|
||||
|
||||
const SettingEmsOutFilPathGet = async (): Promise<string> => {
|
||||
const emsOutFilePath: string = Store.get("settings.emsOutFilePath");
|
||||
return emsOutFilePath;
|
||||
};
|
||||
const SettingEmsOutFilPathSet = 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.emsOutFilePath", result.filePaths[0]); //There should only ever be on directory that was selected.
|
||||
}
|
||||
|
||||
return (Store.get("settings.emsOutFilePath") as string) || "";
|
||||
};
|
||||
|
||||
export {
|
||||
SettingsPpcFilPathGet,
|
||||
SettingsPpcFilPathSet,
|
||||
@@ -104,4 +125,6 @@ export {
|
||||
SettingsWatchedFilePathsRemove,
|
||||
SettingsWatcherPollingGet,
|
||||
SettingsWatcherPollingSet,
|
||||
SettingEmsOutFilPathGet,
|
||||
SettingEmsOutFilPathSet,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user