feat: creating notification for update available

This commit is contained in:
Zamitto 2024-07-04 19:59:20 -03:00
parent 4be3db8007
commit b09f2c055f
4 changed files with 38 additions and 7 deletions

View file

@ -3,6 +3,10 @@ import { registerEvent } from "../register-event";
import updater, { UpdateInfo } from "electron-updater";
import { WindowManager } from "@main/services";
import { app } from "electron";
import {
publishNotificationUpdateAvailable,
publishNotificationUpdateReadyToInstall,
} from "@main/services/notifications";
const { autoUpdater } = updater;
@ -24,14 +28,18 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
autoUpdater
.once("update-available", (info: UpdateInfo) => {
sendEvent({ type: "update-available", info });
if (!isAutoInstallAvailable) {
publishNotificationUpdateAvailable();
}
})
.once("update-downloaded", () => {
sendEvent({ type: "update-downloaded" });
publishNotificationUpdateReadyToInstall();
});
if (app.isPackaged) {
autoUpdater.autoDownload = isAutoInstallAvailable;
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.checkForUpdates();
} else if (sendEventsForDebug) {
mockValuesForDebug();
}