feature/IO-3066-1-scaffolding: Minor cleanup

This commit is contained in:
Dave Richer
2025-04-16 14:55:11 -04:00
parent 8b7280f66c
commit b683d054ed
10 changed files with 69 additions and 46 deletions

View File

@@ -12,7 +12,7 @@ import { handlePartsPriceChangeRequest } from "../ppc/ppc-handler";
import { handleQuickBookRequest } from "../quickbooks-desktop/quickbooks-desktop";
export default class LocalServer {
private app: express.Application;
private readonly app: express.Application;
private server: http.Server | null;
private PORT = 1337;
@@ -149,7 +149,7 @@ export default class LocalServer {
);
this.app.post(
"/refresh",
async (req: express.Request, res: express.Response) => {
async (_req: express.Request, res: express.Response) => {
log.debug("[HTTP Server] Refresh request received");
try {
await handleShopMetaDataFetch(true);

View File

@@ -67,6 +67,7 @@ function createWindow(): void {
const template: Electron.MenuItemConstructorOptions[] = [
// { role: 'appMenu' }
// @ts-ignore
...(isMac
? [
{
@@ -89,7 +90,9 @@ function createWindow(): void {
{
label: "File",
submenu: [
// @ts-ignore
...(!isMac ? [{ role: "about" }] : []),
// @ts-ignore
isMac ? { role: "close" } : { role: "quit" },
],
},
@@ -103,6 +106,7 @@ function createWindow(): void {
{ role: "cut" },
{ role: "copy" },
{ role: "paste" },
// @ts-ignore
...(isMac
? [
{ role: "pasteAndMatchStyle" },
@@ -120,6 +124,7 @@ function createWindow(): void {
// { role: 'viewMenu' }
{
label: "View",
// @ts-ignore
submenu: [
{ role: "reload" },
{ role: "forceReload" },
@@ -134,6 +139,7 @@ function createWindow(): void {
},
{
label: "Application",
// @ts-ignore
submenu: [
{
label: "Open on Startup",
@@ -235,6 +241,7 @@ function createWindow(): void {
submenu: [
{ role: "minimize" },
{ role: "zoom" },
// @ts-ignore
...(isMac
? [
{ type: "separator" },
@@ -257,6 +264,7 @@ function createWindow(): void {
// Update the menu to make the hidden item visible
// Find the menu item dynamically by its id
const fileMenu = template.find((item) => item.label === "Application");
// @ts-ignore
const hiddenItem = fileMenu?.submenu?.find(
(item) => item.id === "development",
);
@@ -375,7 +383,7 @@ app.whenReady().then(async () => {
// module.someFunction()
log.debug("Successfully loaded ipcMainConfig", module);
} catch (error) {
log.error("Failed to load ipcMainconfig", {
log.error("Failed to load ipcMainConfig", {
...ErrorTypeCheck(error),
});
}
@@ -409,7 +417,7 @@ app.whenReady().then(async () => {
// if (import.meta.env.DEV) {
// // Useful for some dev/debugging tasks, but download can
// // not be validated becuase dev app is not signed
// // not be validated because dev app is not signed
// autoUpdater.channel = "alpha";
// autoUpdater.updateConfigPath = path.join(
// __dirname,

View File

@@ -38,8 +38,7 @@ const SettingsWatchedFilePathsRemove = async (
};
const SettingsWatchedFilePathsGet = async (): Promise<string[]> => {
const filepaths: string[] = Store.get("settings.filepaths") || [];
return filepaths;
return Store.get("settings.filepaths") || [];
};
const SettingsWatcherPollingGet = async (): Promise<{
@@ -66,7 +65,7 @@ const SettingsWatcherPollingSet = async (
//Restart the watcher with these new settings.
await StopWatcher();
StartWatcher();
await StartWatcher();
return { enabled, interval };
};

View File

@@ -36,7 +36,7 @@ const ipcMainHandleAuthStateChanged = async (
}
} catch (error) {
log.error(
"Error while querying active bodyshop or masterdata",
"Error while querying active bodyshop or master data",
errorTypeCheck(error),
);
sendIpcToRenderer(
@@ -48,7 +48,7 @@ const ipcMainHandleAuthStateChanged = async (
};
const handleShopMetaDataFetch = async (
reloadWindow: boolean,
reloadWindow?: boolean,
): Promise<void> => {
try {
log.debug("Requery shop information & master data.");

View File

@@ -3,9 +3,9 @@ import fs from "fs";
import path from "path";
import errorTypeCheck from "../../util/errorTypeCheck";
const createdDirectoryIfNotExist = async (dirpath: string) => {
const createdDirectoryIfNotExist = async (dirPath: string) => {
try {
const directoryPath = path.dirname(dirpath);
const directoryPath = path.dirname(dirPath);
if (!fs.existsSync(directoryPath)) {
log.info(`Directory does not exist. Creating: ${directoryPath}`);
fs.mkdirSync(directoryPath, { recursive: true });

View File

@@ -1,9 +1,8 @@
import { BrowserWindow } from "electron";
import {BrowserWindow} from "electron";
import log from "electron-log/main";
const getMainWindow = (): Electron.BrowserWindow => {
const mainWindow = BrowserWindow.getAllWindows()[0];
return mainWindow;
return BrowserWindow.getAllWindows()[0];
};
const sendIpcToRenderer = (ipcMessage: string, ...args: any[]): void => {

View File

@@ -13,12 +13,9 @@ function uppercaseObjectKeys<T extends Record<string, any>>(
return Object.entries(obj).reduce(
(result, [key, value]) => {
const uppercaseKey = key.toUpperCase();
const newValue =
typeof value === "object" && value !== null
result[uppercaseKey] = typeof value === "object" && value !== null
? uppercaseObjectKeys(value)
: value;
result[uppercaseKey] = newValue;
return result;
},
{} as Record<string, any>,