mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 04:41:03 +00:00
feat: refactors
This commit is contained in:
@@ -10,8 +10,11 @@ const sendEvent = (event: AppUpdaterEvents) => {
|
||||
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
|
||||
};
|
||||
|
||||
const sendEventsForDebug = false;
|
||||
|
||||
const mockValuesForDebug = () => {
|
||||
sendEvent({ type: "update-available", info: { version: "1.3.0" } });
|
||||
sendEvent({ type: "update-downloaded" });
|
||||
};
|
||||
|
||||
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
@@ -19,15 +22,9 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
sendEvent({ type: "update-available", info });
|
||||
});
|
||||
|
||||
if (process.platform !== "darwin") {
|
||||
autoUpdater.once("update-downloaded", () => {
|
||||
sendEvent({ type: "update-downloaded" });
|
||||
});
|
||||
}
|
||||
|
||||
if (app.isPackaged) {
|
||||
autoUpdater.checkForUpdates();
|
||||
} else {
|
||||
} else if (sendEventsForDebug) {
|
||||
mockValuesForDebug();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import { app } from "electron";
|
||||
import { registerEvent } from "../register-event";
|
||||
import updater from "electron-updater";
|
||||
import { releasesPageUrl } from "@main/constants";
|
||||
|
||||
const { autoUpdater } = updater;
|
||||
|
||||
const restartAndInstallUpdate = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
autoUpdater.removeAllListeners();
|
||||
if (app.isPackaged) {
|
||||
if (process.platform === "darwin") {
|
||||
open(`${releasesPageUrl}`);
|
||||
} else {
|
||||
autoUpdater.quitAndInstall(true, true);
|
||||
}
|
||||
autoUpdater.quitAndInstall(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user