Add updater channels.

This commit is contained in:
Patrick Fic
2025-03-31 15:20:18 -07:00
parent eeaeba2252
commit 586a076015
9 changed files with 477 additions and 73 deletions

View File

@@ -8,6 +8,7 @@ export interface ActiveBodyshopQueryResult {
id: string;
shopname: string;
region_config: string;
convenient_company: string;
}>;
}
// No variables needed for this query
@@ -22,6 +23,7 @@ export const QUERY_ACTIVE_BODYSHOP_TYPED: TypedQueryDocumentNode<
id
shopname
region_config
convenient_company
}
}
`) as TypedQueryDocumentNode<ActiveBodyshopQueryResult, Record<never, never>>;

View File

@@ -355,9 +355,7 @@ app.whenReady().then(async () => {
const mainWindow = BrowserWindow.getAllWindows()[0];
mainWindow?.webContents.send(ipcTypes.toRenderer.updates.downloaded, info);
});
//autoUpdater.checkForUpdates();
autoUpdater.checkForUpdatesAndNotify();
//The update itself will run when the bodyshop record is queried to know what release channel to use.
createWindow();
app.on("activate", function () {

View File

@@ -1,4 +1,6 @@
import { IpcMainEvent } from "electron";
import log from "electron-log/main";
import { autoUpdater } from "electron-updater";
import { User } from "firebase/auth";
import client from "../graphql/graphql-client";
import {
@@ -8,7 +10,6 @@ import {
QUERY_MASTERDATA_TYPED,
} from "../graphql/queries";
import Store from "../store/store";
import log from "electron-log/main";
const ipcMainHandleAuthStateChanged = async (
event: IpcMainEvent,
@@ -33,6 +34,15 @@ const ipcMainHandleAuthStateChanged = async (
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";
}
autoUpdater.checkForUpdatesAndNotify();
};
export { ipcMainHandleAuthStateChanged };