Resolve auto updater issue for mac.
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
globalShortcut,
|
||||
ipcMain,
|
||||
Menu,
|
||||
nativeImage,
|
||||
shell,
|
||||
@@ -371,16 +372,19 @@ app.whenReady().then(async () => {
|
||||
|
||||
//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;
|
||||
// //autoUpdater.autoDownload = false;
|
||||
// }
|
||||
|
||||
autoUpdater.on("checking-for-update", () => {
|
||||
log.info("Checking for update...");
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
@@ -406,6 +410,12 @@ app.whenReady().then(async () => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
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();
|
||||
|
||||
@@ -430,6 +440,17 @@ app.on("window-all-closed", () => {
|
||||
});
|
||||
|
||||
app.on("before-quit", () => {
|
||||
preQuitMethods();
|
||||
});
|
||||
|
||||
//We need to hit the prequit methods from here as well to ensure the app quits and restarts.
|
||||
ipcMain.on(ipcTypes.toMain.updates.apply, () => {
|
||||
log.info("Applying update from renderer.");
|
||||
preQuitMethods();
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
function preQuitMethods(): void {
|
||||
localServer.stop();
|
||||
const currentSetting = store.get("app.openOnStartup") as boolean;
|
||||
store.set("app.openOnStartup", !currentSetting);
|
||||
@@ -442,7 +463,7 @@ app.on("before-quit", () => {
|
||||
}
|
||||
globalShortcut.unregisterAll();
|
||||
isAppQuitting = true;
|
||||
});
|
||||
}
|
||||
|
||||
function openMainWindow(): void {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
|
||||
@@ -132,9 +132,4 @@ ipcMain.on(ipcTypes.toMain.updates.checkForUpdates, () => {
|
||||
autoUpdater.checkForUpdates();
|
||||
});
|
||||
|
||||
ipcMain.on(ipcTypes.toMain.updates.apply, () => {
|
||||
log.info("Applying update from renderer.");
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
logIpcMessages();
|
||||
|
||||
Reference in New Issue
Block a user