Resolve auto updater issue for mac.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bodyshop-desktop",
|
"name": "bodyshop-desktop",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.1-alpha.1",
|
||||||
"description": "Shop Management System Partner",
|
"description": "Shop Management System Partner",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "Convenient Brands, LLC",
|
"author": "Convenient Brands, LLC",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
app,
|
app,
|
||||||
BrowserWindow,
|
BrowserWindow,
|
||||||
globalShortcut,
|
globalShortcut,
|
||||||
|
ipcMain,
|
||||||
Menu,
|
Menu,
|
||||||
nativeImage,
|
nativeImage,
|
||||||
shell,
|
shell,
|
||||||
@@ -371,16 +372,19 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
//Check for app updates.
|
//Check for app updates.
|
||||||
autoUpdater.logger = log;
|
autoUpdater.logger = log;
|
||||||
|
|
||||||
// if (import.meta.env.DEV) {
|
// if (import.meta.env.DEV) {
|
||||||
// // Useful for some dev/debugging tasks, but download can
|
// // Useful for some dev/debugging tasks, but download can
|
||||||
// // not be validated becuase dev app is not signed
|
// // not be validated becuase dev app is not signed
|
||||||
|
// autoUpdater.channel = "alpha";
|
||||||
// autoUpdater.updateConfigPath = path.join(
|
// autoUpdater.updateConfigPath = path.join(
|
||||||
// __dirname,
|
// __dirname,
|
||||||
// "../../dev-app-update.yml",
|
// "../../dev-app-update.yml",
|
||||||
// );
|
// );
|
||||||
// autoUpdater.forceDevUpdateConfig = true;
|
// autoUpdater.forceDevUpdateConfig = true;
|
||||||
// autoUpdater.autoDownload = false;
|
// //autoUpdater.autoDownload = false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
autoUpdater.on("checking-for-update", () => {
|
autoUpdater.on("checking-for-update", () => {
|
||||||
log.info("Checking for update...");
|
log.info("Checking for update...");
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||||
@@ -406,6 +410,12 @@ app.whenReady().then(async () => {
|
|||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||||
mainWindow?.webContents.send(ipcTypes.toRenderer.updates.downloaded, info);
|
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.
|
//The update itself will run when the bodyshop record is queried to know what release channel to use.
|
||||||
createWindow();
|
createWindow();
|
||||||
|
|
||||||
@@ -430,6 +440,17 @@ app.on("window-all-closed", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.on("before-quit", () => {
|
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();
|
localServer.stop();
|
||||||
const currentSetting = store.get("app.openOnStartup") as boolean;
|
const currentSetting = store.get("app.openOnStartup") as boolean;
|
||||||
store.set("app.openOnStartup", !currentSetting);
|
store.set("app.openOnStartup", !currentSetting);
|
||||||
@@ -442,7 +463,7 @@ app.on("before-quit", () => {
|
|||||||
}
|
}
|
||||||
globalShortcut.unregisterAll();
|
globalShortcut.unregisterAll();
|
||||||
isAppQuitting = true;
|
isAppQuitting = true;
|
||||||
});
|
}
|
||||||
|
|
||||||
function openMainWindow(): void {
|
function openMainWindow(): void {
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||||
|
|||||||
@@ -132,9 +132,4 @@ ipcMain.on(ipcTypes.toMain.updates.checkForUpdates, () => {
|
|||||||
autoUpdater.checkForUpdates();
|
autoUpdater.checkForUpdates();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(ipcTypes.toMain.updates.apply, () => {
|
|
||||||
log.info("Applying update from renderer.");
|
|
||||||
autoUpdater.quitAndInstall();
|
|
||||||
});
|
|
||||||
|
|
||||||
logIpcMessages();
|
logIpcMessages();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const UpdateAvailable: React.FC = () => {
|
|||||||
percent={updateProgress}
|
percent={updateProgress}
|
||||||
percentPosition={{ align: "center", type: "outer" }}
|
percentPosition={{ align: "center", type: "outer" }}
|
||||||
/>
|
/>
|
||||||
{formatSpeed(updateSpeed)}
|
{!isUpdateComplete && formatSpeed(updateSpeed)}
|
||||||
{isUpdateComplete && (
|
{isUpdateComplete && (
|
||||||
<Button onClick={handleApply}>{t("updates.apply")}</Button>
|
<Button onClick={handleApply}>{t("updates.apply")}</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -61,7 +61,13 @@ ipcRenderer.on(ipcTypes.toRenderer.updates.available, () => {
|
|||||||
ipcRenderer.on(
|
ipcRenderer.on(
|
||||||
ipcTypes.toRenderer.updates.downloading,
|
ipcTypes.toRenderer.updates.downloading,
|
||||||
(_event: Electron.IpcRendererEvent, arg) => {
|
(_event: Electron.IpcRendererEvent, arg) => {
|
||||||
dispatch(updateProgress({ progress: arg.progress, speed: arg.speed }));
|
console.log("*** ARg", arg);
|
||||||
|
dispatch(
|
||||||
|
updateProgress({
|
||||||
|
progress: Math.round(arg.percent),
|
||||||
|
speed: arg.bytesPerSecond,
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
ipcRenderer.on(ipcTypes.toRenderer.updates.downloaded, () => {
|
ipcRenderer.on(ipcTypes.toRenderer.updates.downloaded, () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user