Minor bug fixes and CI change.

This commit is contained in:
Patrick Fic
2025-04-01 10:16:24 -07:00
parent ab3de9a382
commit 88dd8adfa5
12 changed files with 150 additions and 38 deletions

View File

@@ -1,4 +1,4 @@
import { IpcMainEvent } from "electron";
import { IpcMainEvent, shell } from "electron";
import log from "electron-log/main";
import { autoUpdater } from "electron-updater";
import { User } from "firebase/auth";
@@ -10,39 +10,59 @@ import {
QUERY_MASTERDATA_TYPED,
} from "../graphql/queries";
import Store from "../store/store";
import errorTypeCheck from "../../util/errorTypeCheck";
import { sendIpcToRenderer } from "../util/toRenderer";
import ipcTypes from "../../util/ipcTypes.json";
const ipcMainHandleAuthStateChanged = async (
event: IpcMainEvent,
_event: IpcMainEvent,
user: User | null,
): Promise<void> => {
Store.set("user", user);
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,
);
//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]);
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.");
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.");
//Check for updates
const convCo = activeBodyshop.bodyshops[0].convenient_company;
if (convCo === "alpha") {
autoUpdater.channel = "alpha";
} else if (convCo === "beta") {
autoUpdater.channel = "beta";
//Check for updates
const convCo = activeBodyshop.bodyshops[0].convenient_company;
if (convCo === "alpha") {
autoUpdater.channel = "alpha";
} else if (convCo === "beta") {
autoUpdater.channel = "beta";
}
} catch (error) {
log.error(
"Error while querying active bodyshop or masterdata",
errorTypeCheck(error),
);
sendIpcToRenderer(
ipcTypes.toRenderer.general.showErrorMessage,
"Error connecting to ImEX Online servers to get shop data. Please try again.",
);
}
autoUpdater.checkForUpdatesAndNotify();
};
export { ipcMainHandleAuthStateChanged };
const ipMainHandleResetPassword = async (): Promise<void> => {
shell.openExternal("https://imex.online/resetpassword");
};
export { ipcMainHandleAuthStateChanged, ipMainHandleResetPassword };