mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-21 10:03:56 +00:00
feat: creating notification for update available
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -39,11 +39,9 @@ export const publishDownloadCompleteNotification = async (game: Game) => {
|
||||
new Notification({
|
||||
title: t("download_complete", {
|
||||
ns: "notifications",
|
||||
lng: userPreferences.language,
|
||||
}),
|
||||
body: t("game_ready_to_install", {
|
||||
ns: "notifications",
|
||||
lng: userPreferences.language,
|
||||
title: game.title,
|
||||
}),
|
||||
icon,
|
||||
@@ -60,13 +58,33 @@ export const publishNewRepacksNotifications = async (count: number) => {
|
||||
new Notification({
|
||||
title: t("repack_list_updated", {
|
||||
ns: "notifications",
|
||||
lng: userPreferences?.language || "en",
|
||||
}),
|
||||
body: t("repack_count", {
|
||||
ns: "notifications",
|
||||
lng: userPreferences?.language || "en",
|
||||
count: count,
|
||||
}),
|
||||
}).show();
|
||||
}
|
||||
};
|
||||
|
||||
export const publishNotificationUpdateReadyToInstall = async () => {
|
||||
new Notification({
|
||||
title: t("new_version_title", {
|
||||
ns: "notifications",
|
||||
}),
|
||||
body: t("new_version_body", {
|
||||
ns: "notifications",
|
||||
}),
|
||||
}).show();
|
||||
};
|
||||
|
||||
export const publishNotificationUpdateAvailable = async () => {
|
||||
new Notification({
|
||||
title: t("new_version_title", {
|
||||
ns: "notifications",
|
||||
}),
|
||||
body: t("new_version_body", {
|
||||
ns: "notifications",
|
||||
}),
|
||||
}).show();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user