mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-22 02:13:59 +00:00
feat: refactors
This commit is contained in:
@@ -28,8 +28,6 @@ export const databasePath = path.join(
|
||||
|
||||
export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
|
||||
|
||||
export const releasesPageUrl = "https://github.com/hydralauncher/hydra";
|
||||
|
||||
export const seedsPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, "seeds")
|
||||
: path.join(__dirname, "..", "..", "seeds");
|
||||
|
||||
@@ -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