General bug fixes from testing, refresh on shop change, update display
This commit is contained in:
@@ -6,9 +6,11 @@ import http from "http";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
import ImportJob from "../decoder/decoder";
|
||||
import folderScan from "../decoder/folder-scan";
|
||||
import { handleEMSPartsOrder } from "../ems-parts-order/ems-parts-order-handler";
|
||||
import { handleShopMetaDataFetch } from "../ipc/ipcMainHandler.user";
|
||||
import { handlePartsPariceChangeRequest } from "../ppc/ppc-handler";
|
||||
import { handleQuickBookRequest } from "../quickbooks-desktop/quickbooks-desktop";
|
||||
import { handleEMSPartsOrder } from "../ems-parts-order/ems-parts-order-handler";
|
||||
import { c } from "vite/dist/node/moduleRunnerTransport.d-CXw_Ws6P";
|
||||
|
||||
export default class LocalServer {
|
||||
private app: express.Application;
|
||||
@@ -146,6 +148,26 @@ export default class LocalServer {
|
||||
}
|
||||
},
|
||||
);
|
||||
this.app.post(
|
||||
"/refresh",
|
||||
async (req: express.Request, res: express.Response) => {
|
||||
log.debug("[HTTP Server] Refresh request received");
|
||||
try {
|
||||
await handleShopMetaDataFetch(true);
|
||||
res.status(200).json({ success: true });
|
||||
} catch (error) {
|
||||
log.error(
|
||||
"[HTTP Server] Error refreshing shop metadata",
|
||||
errorTypeCheck(error),
|
||||
);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
error: "Error importing file",
|
||||
...errorTypeCheck(error),
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Add more routes as needed
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { is, optimizer } from "@electron-toolkit/utils";
|
||||
import { is, optimizer, platform } from "@electron-toolkit/utils";
|
||||
import Sentry from "@sentry/electron/main";
|
||||
import {
|
||||
app,
|
||||
@@ -88,7 +88,10 @@ function createWindow(): void {
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: "File",
|
||||
submenu: [isMac ? { role: "close" } : { role: "quit" }],
|
||||
submenu: [
|
||||
...(!isMac ? [{ role: "about" }] : []),
|
||||
isMac ? { role: "close" } : { role: "quit" },
|
||||
],
|
||||
},
|
||||
// { role: 'editMenu' }
|
||||
{
|
||||
@@ -149,7 +152,7 @@ function createWindow(): void {
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Check for Updates",
|
||||
label: `Check for Updates (${app.getVersion()})`,
|
||||
click: (): void => {
|
||||
checkForAppUpdates();
|
||||
},
|
||||
@@ -169,6 +172,7 @@ function createWindow(): void {
|
||||
store.set("app.isTest", !currentSetting);
|
||||
log.info("Setting isTest to: ", !currentSetting);
|
||||
app.relaunch(); // Relaunch the app
|
||||
preQuitMethods(); //Quitting handlers aren't called. Manually execute to clean up the app.
|
||||
app.exit(0); // Exit the current instance
|
||||
},
|
||||
},
|
||||
@@ -321,6 +325,10 @@ app.whenReady().then(async () => {
|
||||
// Default open or close DevTools by F12 in development
|
||||
// and ignore CommandOrControl + R in production.
|
||||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
||||
if (platform.isWindows) {
|
||||
app.setAppUserModelId(app.name);
|
||||
}
|
||||
|
||||
app.on("browser-window-created", (_, window) => {
|
||||
optimizer.watchWindowShortcuts(window);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "../graphql/queries";
|
||||
import { default as Store, default as store } from "../store/store";
|
||||
import { checkForAppUpdatesContinuously } from "../util/checkForAppUpdates";
|
||||
import { sendIpcToRenderer } from "../util/toRenderer";
|
||||
import { getMainWindow, sendIpcToRenderer } from "../util/toRenderer";
|
||||
|
||||
const ipcMainHandleAuthStateChanged = async (
|
||||
_event: IpcMainEvent,
|
||||
@@ -23,27 +23,10 @@ const ipcMainHandleAuthStateChanged = async (
|
||||
try {
|
||||
//Need to query the currently active shop, and store the metadata as well.
|
||||
//Also need to query the OP Codes for decoding reference.
|
||||
const activeBodyshop: ActiveBodyshopQueryResult = await client.request(
|
||||
QUERY_ACTIVE_BODYSHOP_TYPED,
|
||||
);
|
||||
|
||||
Store.set("app.bodyshop", activeBodyshop.bodyshops[0]);
|
||||
|
||||
const OpCodes: MasterdataQueryResult = await client.request(
|
||||
QUERY_MASTERDATA_TYPED,
|
||||
{
|
||||
key: `${activeBodyshop.bodyshops[0].region_config}_ciecaopcodes`,
|
||||
},
|
||||
);
|
||||
Store.set(
|
||||
"app.masterdata.opcodes",
|
||||
JSON.parse(OpCodes.masterdata[0]?.value),
|
||||
);
|
||||
log.debug("Received authentication state change from Renderer.", user);
|
||||
log.debug("Requery shop information & master data.");
|
||||
|
||||
handleShopMetaDataFetch();
|
||||
//Check for updates
|
||||
const convCo = activeBodyshop.bodyshops[0].convenient_company;
|
||||
const convCo = Store.get("app.bodyshop");
|
||||
if (convCo === "alpha") {
|
||||
autoUpdater.channel = "alpha";
|
||||
log.debug("Setting update channel to ALPHA channel.");
|
||||
@@ -64,6 +47,39 @@ const ipcMainHandleAuthStateChanged = async (
|
||||
checkForAppUpdatesContinuously();
|
||||
};
|
||||
|
||||
const handleShopMetaDataFetch = async (
|
||||
reloadWindow: boolean,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
log.debug("Requery shop information & master data.");
|
||||
const activeBodyshop: ActiveBodyshopQueryResult = await client.request(
|
||||
QUERY_ACTIVE_BODYSHOP_TYPED,
|
||||
);
|
||||
|
||||
Store.set("app.bodyshop", activeBodyshop.bodyshops[0]);
|
||||
|
||||
const OpCodes: MasterdataQueryResult = await client.request(
|
||||
QUERY_MASTERDATA_TYPED,
|
||||
{
|
||||
key: `${activeBodyshop.bodyshops[0].region_config}_ciecaopcodes`,
|
||||
},
|
||||
);
|
||||
Store.set(
|
||||
"app.masterdata.opcodes",
|
||||
JSON.parse(OpCodes.masterdata[0]?.value),
|
||||
);
|
||||
if (reloadWindow) {
|
||||
const mainWindow = getMainWindow();
|
||||
if (mainWindow) {
|
||||
mainWindow.reload();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
log.error("Error while fetching shop metadata", errorTypeCheck(error));
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const ipMainHandleResetPassword = async (): Promise<void> => {
|
||||
shell.openExternal(
|
||||
store.get("app.isTest")
|
||||
@@ -72,4 +88,8 @@ const ipMainHandleResetPassword = async (): Promise<void> => {
|
||||
);
|
||||
};
|
||||
|
||||
export { ipcMainHandleAuthStateChanged, ipMainHandleResetPassword };
|
||||
export {
|
||||
ipcMainHandleAuthStateChanged,
|
||||
ipMainHandleResetPassword,
|
||||
handleShopMetaDataFetch,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user