mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
create electron event
This commit is contained in:
parent
484e79dba3
commit
3b17953a82
11 changed files with 113 additions and 27 deletions
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);
|
Loading…
Add table
Add a link
Reference in a new issue