mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-28 05:11:02 +00:00
create electron event
This commit is contained in:
42
src/main/events/autoupdater/check-for-updates.ts
Normal file
42
src/main/events/autoupdater/check-for-updates.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { AppUpdaterEvents } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import updater, {
|
||||
ProgressInfo,
|
||||
UpdateDownloadedEvent,
|
||||
UpdateInfo,
|
||||
} from "electron-updater";
|
||||
|
||||
const { autoUpdater } = updater;
|
||||
|
||||
const checkForUpdates = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
cb: (value: AppUpdaterEvents) => void
|
||||
) => {
|
||||
console.log("check for updates event");
|
||||
autoUpdater
|
||||
.addListener("error", (error: Error, message?: string) => {
|
||||
cb({ error, message });
|
||||
})
|
||||
.addListener("checking-for-update", () => {
|
||||
cb("checking-for-updates");
|
||||
})
|
||||
.addListener("update-not-available", (info: UpdateInfo) => {
|
||||
cb(info);
|
||||
})
|
||||
.addListener("update-available", (info: UpdateInfo) => {
|
||||
cb(info);
|
||||
})
|
||||
.addListener("update-downloaded", (event: UpdateDownloadedEvent) => {
|
||||
cb(event);
|
||||
})
|
||||
.addListener("download-progress", (info: ProgressInfo) => {
|
||||
cb(info);
|
||||
})
|
||||
.addListener("update-cancelled", (info: UpdateInfo) => {
|
||||
cb(info);
|
||||
});
|
||||
|
||||
autoUpdater.checkForUpdates();
|
||||
};
|
||||
|
||||
registerEvent("checkForUpdates", checkForUpdates);
|
||||
@@ -27,6 +27,7 @@ import "./torrenting/start-game-download";
|
||||
import "./user-preferences/get-user-preferences";
|
||||
import "./user-preferences/update-user-preferences";
|
||||
import "./user-preferences/auto-launch";
|
||||
import "./autoupdater/check-for-updates";
|
||||
|
||||
ipcMain.handle("ping", () => "pong");
|
||||
ipcMain.handle("getVersion", () => app.getVersion());
|
||||
|
||||
@@ -41,11 +41,14 @@ export class WindowManager {
|
||||
// Load the remote URL for development or the local html file for production.
|
||||
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
|
||||
this.splashWindow?.loadURL(
|
||||
`${process.env["ELECTRON_RENDERER_URL"]}/splash.html`
|
||||
`${process.env["ELECTRON_RENDERER_URL"]}#/splash`
|
||||
);
|
||||
} else {
|
||||
this.splashWindow?.loadFile(
|
||||
path.join(__dirname, "../renderer/splash.html")
|
||||
path.join(__dirname, "../renderer/index.html"),
|
||||
{
|
||||
hash: "splash",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -56,6 +59,10 @@ export class WindowManager {
|
||||
height: 400,
|
||||
frame: true,
|
||||
alwaysOnTop: false,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "../preload/index.mjs"),
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
|
||||
this.loadSplashURL();
|
||||
|
||||
Reference in New Issue
Block a user