diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 9799b12e..e44dc7ea 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_update_available": "Version {{version}} available", + "restart_to_install_update": "Restart Hydra to install the update" }, "system_tray": { "open": "Open Hydra", diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json index a0fdf92a..77b43dd8 100644 --- a/src/locales/es/translation.json +++ b/src/locales/es/translation.json @@ -199,7 +199,8 @@ "game_ready_to_install": "{{title}} está listo para instalarse", "repack_list_updated": "Lista de repacks actualizadas", "repack_count_one": "{{count}} repack ha sido añadido", - "repack_count_other": "{{count}} repacks añadidos" + "repack_count_other": "{{count}} repacks añadidos", + "new_update_available": "Version {{version}} disponible" }, "system_tray": { "open": "Abrir Hydra", diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index 4e8a9158..f1a4e77e 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -195,7 +195,9 @@ "game_ready_to_install": "{{title}} está pronto para ser instalado", "repack_list_updated": "Lista de repacks atualizada", "repack_count_one": "{{count}} novo repack", - "repack_count_other": "{{count}} novos repacks" + "repack_count_other": "{{count}} novos repacks", + "new_update_available": "Versão {{version}} disponível", + "restart_to_install_update": "Reinicie o Hydra para instalar a nova versão" }, "system_tray": { "open": "Abrir Hydra", diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json index 322ad3b4..69a9c33d 100644 --- a/src/locales/ru/translation.json +++ b/src/locales/ru/translation.json @@ -197,7 +197,8 @@ "game_ready_to_install": "{{title}} готова к установке", "repack_list_updated": "Список репаков обновлен", "repack_count_one": "{{count}} репак добавлен", - "repack_count_other": "{{count}} репаков добавлено" + "repack_count_other": "{{count}} репаков добавлено", + "new_update_available": "Доступна версия {{version}}" }, "system_tray": { "open": "Открыть Hydra", diff --git a/src/main/events/autoupdater/check-for-updates.ts b/src/main/events/autoupdater/check-for-updates.ts index f7e37481..6c8d3cb0 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -3,6 +3,7 @@ import { registerEvent } from "../register-event"; import updater, { UpdateInfo } from "electron-updater"; import { WindowManager } from "@main/services"; import { app } from "electron"; +import { publishNotificationUpdateReadyToInstall } from "@main/services/notifications"; const { autoUpdater } = updater; @@ -20,13 +21,17 @@ const mockValuesForDebug = () => { sendEvent({ type: "update-downloaded" }); }; +const newVersionInfo = { version: "" }; + const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => { autoUpdater .once("update-available", (info: UpdateInfo) => { sendEvent({ type: "update-available", info }); + newVersionInfo.version = info.version; }) .once("update-downloaded", () => { sendEvent({ type: "update-downloaded" }); + publishNotificationUpdateReadyToInstall(newVersionInfo.version); }); if (app.isPackaged) { diff --git a/src/main/events/user-preferences/auto-launch.ts b/src/main/events/user-preferences/auto-launch.ts index 712f388b..1f4f9cc3 100644 --- a/src/main/events/user-preferences/auto-launch.ts +++ b/src/main/events/user-preferences/auto-launch.ts @@ -1,6 +1,18 @@ import { registerEvent } from "../register-event"; import AutoLaunch from "auto-launch"; import { app } from "electron"; +import path from "path"; +import fs from "node:fs"; +import { logger } from "@main/services"; + +const windowsStartupPath = path.join( + app.getPath("appData"), + "Microsoft", + "Windows", + "Start Menu", + "Programs", + "Startup" +); const autoLaunch = async ( _event: Electron.IpcMainInvokeEvent, @@ -13,9 +25,17 @@ const autoLaunch = async ( }); if (enabled) { - appLauncher.enable().catch(() => {}); + appLauncher.enable().catch((err) => { + logger.error(err); + }); } else { - appLauncher.disable().catch(() => {}); + if (process.platform == "win32") { + fs.rm(path.join(windowsStartupPath, "Hydra.vbs"), () => {}); + } + + appLauncher.disable().catch((err) => { + logger.error(err); + }); } }; diff --git a/src/main/services/notifications.ts b/src/main/services/notifications.ts index d53cc527..274ffc91 100644 --- a/src/main/services/notifications.ts +++ b/src/main/services/notifications.ts @@ -1,7 +1,7 @@ import { Notification, nativeImage } from "electron"; import { t } from "i18next"; import { parseICO } from "icojs"; - +import trayIcon from "@resources/tray-icon.png?asset"; import { Game } from "@main/entity"; import { gameRepository, userPreferencesRepository } from "@main/repository"; @@ -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,26 @@ 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 ( + version: string +) => { + new Notification({ + title: t("new_update_available", { + ns: "notifications", + version, + }), + body: t("restart_to_install_update", { + ns: "notifications", + }), + icon: trayIcon, + }).show(); +}; diff --git a/src/renderer/src/components/header/auto-update-sub-header.tsx b/src/renderer/src/components/header/auto-update-sub-header.tsx index 8e390946..038d2a9d 100644 --- a/src/renderer/src/components/header/auto-update-sub-header.tsx +++ b/src/renderer/src/components/header/auto-update-sub-header.tsx @@ -47,10 +47,8 @@ export function AutoUpdateSubHeader() { return (
- - + {t("version_available_download", { version: newVersion })} -
); @@ -64,10 +62,8 @@ export function AutoUpdateSubHeader() { className={styles.newVersionButton} onClick={handleClickInstallUpdate} > - - + {t("version_available_install", { version: newVersion })} - ); diff --git a/src/renderer/src/components/header/header.css.ts b/src/renderer/src/components/header/header.css.ts index 65445991..0e82aaef 100644 --- a/src/renderer/src/components/header/header.css.ts +++ b/src/renderer/src/components/header/header.css.ts @@ -157,7 +157,7 @@ export const newVersionButton = style({ justifyContent: "center", gap: `${SPACING_UNIT}px`, color: vars.color.body, - fontSize: "13px", + fontSize: "12px", ":hover": { textDecoration: "underline", cursor: "pointer", @@ -169,5 +169,9 @@ export const newVersionLink = style({ alignItems: "center", gap: `${SPACING_UNIT}px`, color: "#8e919b", - fontSize: "13px", + fontSize: "12px", +}); + +export const newVersionIcon = style({ + color: vars.color.success, });