diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 9799b12e..69c09278 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -199,7 +199,9 @@ "game_ready_to_install": "{{title}} is ready to install", "repack_list_updated": "Repack list updated", "repack_count_one": "{{count}} repack added", - "repack_count_other": "{{count}} repacks added" + "repack_count_other": "{{count}} repacks added", + "new_version_title": "New Hydra version available", + "new_version_body": "Restart Hydra to install the new version" }, "system_tray": { "open": "Open Hydra", diff --git a/src/main/events/autoupdater/check-for-updates.ts b/src/main/events/autoupdater/check-for-updates.ts index 99a65f88..30e7a7db 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -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(); } diff --git a/src/main/services/notifications.ts b/src/main/services/notifications.ts index d53cc527..2fb3c5da 100644 --- a/src/main/services/notifications.ts +++ b/src/main/services/notifications.ts @@ -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(); +}; diff --git a/src/renderer/src/pages/game-details/modals/repacks-modal.tsx b/src/renderer/src/pages/game-details/modals/repacks-modal.tsx index feae8e0e..1d368798 100644 --- a/src/renderer/src/pages/game-details/modals/repacks-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/repacks-modal.tsx @@ -40,7 +40,10 @@ export function RepacksModal({ const getInfoHash = useCallback(async () => { const torrent = await parseTorrent(game?.uri ?? ""); - if (torrent.infoHash) setInfoHash(torrent.infoHash); + + if (torrent.infoHash) { + setInfoHash(torrent.infoHash); + } }, [game]); useEffect(() => {