Change auto updater to check continuously. Add Double click to tray.

This commit is contained in:
Patrick Fic
2025-04-10 14:54:31 -07:00
parent 7e2c068e52
commit e111dbbf51
5 changed files with 47 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "bodyshop-desktop",
"version": "0.0.1-alpha.0",
"version": "0.0.1-alpha.2",
"description": "Shop Management System Partner",
"main": "./out/main/index.js",
"author": "Convenient Brands, LLC",

View File

@@ -22,6 +22,7 @@ import ipcTypes from "../util/ipcTypes.json";
import ImportJob from "./decoder/decoder";
import LocalServer from "./http-server/http-server";
import store from "./store/store";
import { checkForAppUpdates } from "./util/checkForAppUpdates";
import { getMainWindow } from "./util/toRenderer";
import { GetAllEnvFiles } from "./watcher/watcher";
@@ -147,6 +148,12 @@ function createWindow(): void {
}
},
},
{
label: "Check for Updates",
click: (): void => {
checkForAppUpdates();
},
},
{
label: "Development",
id: "development",
@@ -169,7 +176,7 @@ function createWindow(): void {
{
label: "Check for updates",
click: (): void => {
autoUpdater.checkForUpdates();
checkForAppUpdates();
},
},
{
@@ -369,22 +376,26 @@ app.whenReady().then(async () => {
},
]);
tray.on("double-click", () => {
openMainWindow();
});
tray.setContextMenu(contextMenu);
//Check for app updates.
autoUpdater.logger = log;
if (import.meta.env.DEV) {
// Useful for some dev/debugging tasks, but download can
// not be validated becuase dev app is not signed
autoUpdater.channel = "alpha";
autoUpdater.updateConfigPath = path.join(
__dirname,
"../../dev-app-update.yml",
);
autoUpdater.forceDevUpdateConfig = true;
//autoUpdater.autoDownload = false;
}
// if (import.meta.env.DEV) {
// // Useful for some dev/debugging tasks, but download can
// // not be validated becuase dev app is not signed
// autoUpdater.channel = "alpha";
// autoUpdater.updateConfigPath = path.join(
// __dirname,
// "../../dev-app-update.yml",
// );
// autoUpdater.forceDevUpdateConfig = true;
// //autoUpdater.autoDownload = false;
// }
autoUpdater.on("checking-for-update", () => {
log.info("Checking for update...");
@@ -412,11 +423,6 @@ app.whenReady().then(async () => {
mainWindow?.webContents.send(ipcTypes.toRenderer.updates.downloaded, info);
});
autoUpdater.checkForUpdatesAndNotify({
title: "Shop Partner Update",
body: "A new version of Shop Partner is available. Click to update.",
});
//The update itself will run when the bodyshop record is queried to know what release channel to use.
createWindow();

View File

@@ -127,9 +127,4 @@ ipcMain.on(ipcTypes.toMain.updates.download, () => {
autoUpdater.downloadUpdate();
});
ipcMain.on(ipcTypes.toMain.updates.checkForUpdates, () => {
log.info("Checking for updates from renderer.");
autoUpdater.checkForUpdates();
});
logIpcMessages();

View File

@@ -2,6 +2,8 @@ import { IpcMainEvent, shell } from "electron";
import log from "electron-log/main";
import { autoUpdater } from "electron-updater";
import { User } from "firebase/auth";
import errorTypeCheck from "../../util/errorTypeCheck";
import ipcTypes from "../../util/ipcTypes.json";
import client from "../graphql/graphql-client";
import {
ActiveBodyshopQueryResult,
@@ -10,9 +12,8 @@ import {
QUERY_MASTERDATA_TYPED,
} from "../graphql/queries";
import Store from "../store/store";
import errorTypeCheck from "../../util/errorTypeCheck";
import { checkForAppUpdatesContinuously } from "../util/checkForAppUpdates";
import { sendIpcToRenderer } from "../util/toRenderer";
import ipcTypes from "../../util/ipcTypes.json";
const ipcMainHandleAuthStateChanged = async (
_event: IpcMainEvent,
@@ -60,7 +61,7 @@ const ipcMainHandleAuthStateChanged = async (
"Error connecting to ImEX Online servers to get shop data. Please try again.",
);
}
autoUpdater.checkForUpdatesAndNotify();
checkForAppUpdatesContinuously();
};
const ipMainHandleResetPassword = async (): Promise<void> => {

View File

@@ -0,0 +1,19 @@
import { autoUpdater } from "electron-updater";
function checkForAppUpdatesContinuously(): void {
checkForAppUpdates();
setInterval(
() => {
checkForAppUpdatesContinuously();
},
1000 * 60 * 30,
);
}
function checkForAppUpdates(): void {
autoUpdater.checkForUpdatesAndNotify({
title: "Shop Partner Update",
body: "A new version of Shop Partner is available. Click to update.",
});
}
export { checkForAppUpdatesContinuously, checkForAppUpdates };