From d481164bf3f64a746ab38651c7716596746cdf3d Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:03:50 -0300 Subject: [PATCH 01/10] feat: add color to update icon and notify --- src/main/events/autoupdater/check-for-updates.ts | 2 +- src/renderer/src/components/header/auto-update-sub-header.tsx | 4 ++-- src/renderer/src/components/header/header.css.ts | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/events/autoupdater/check-for-updates.ts b/src/main/events/autoupdater/check-for-updates.ts index f7e37481..99a65f88 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -31,7 +31,7 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => { if (app.isPackaged) { autoUpdater.autoDownload = isAutoInstallAvailable; - autoUpdater.checkForUpdates(); + autoUpdater.checkForUpdatesAndNotify(); } else if (sendEventsForDebug) { mockValuesForDebug(); } 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..3d3cb18f 100644 --- a/src/renderer/src/components/header/auto-update-sub-header.tsx +++ b/src/renderer/src/components/header/auto-update-sub-header.tsx @@ -47,7 +47,7 @@ export function AutoUpdateSubHeader() { return (
- + {t("version_available_download", { version: newVersion })} @@ -64,7 +64,7 @@ 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..c93a8fe9 100644 --- a/src/renderer/src/components/header/header.css.ts +++ b/src/renderer/src/components/header/header.css.ts @@ -171,3 +171,7 @@ export const newVersionLink = style({ color: "#8e919b", fontSize: "13px", }); + +export const newVersionIcon = style({ + color: vars.color.success, +}); From 29b64237ed836ee5918ad379aaf7525e50b5f4c7 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:57:03 -0300 Subject: [PATCH 02/10] feat: remove old vbs file --- src/main/events/user-preferences/auto-launch.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/events/user-preferences/auto-launch.ts b/src/main/events/user-preferences/auto-launch.ts index 712f388b..fc05fb62 100644 --- a/src/main/events/user-preferences/auto-launch.ts +++ b/src/main/events/user-preferences/auto-launch.ts @@ -1,6 +1,17 @@ import { registerEvent } from "../register-event"; import AutoLaunch from "auto-launch"; import { app } from "electron"; +import path from "path"; +import fs from "node:fs"; + +const windowsStartupPath = path.join( + app.getPath("appData"), + "Microsoft", + "Windows", + "Start Menu", + "Programs", + "Startup" +); const autoLaunch = async ( _event: Electron.IpcMainInvokeEvent, @@ -15,6 +26,10 @@ const autoLaunch = async ( if (enabled) { appLauncher.enable().catch(() => {}); } else { + if (process.platform == "win32") { + fs.rm(path.join(windowsStartupPath, "Hydra.vbs"), () => {}); + } + appLauncher.disable().catch(() => {}); } }; From 4be3db8007d6fed81cb7f77c369f456035ef5a7e Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Wed, 3 Jul 2024 18:03:11 -0300 Subject: [PATCH 03/10] feat: add error logs --- src/main/events/user-preferences/auto-launch.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/events/user-preferences/auto-launch.ts b/src/main/events/user-preferences/auto-launch.ts index fc05fb62..1f4f9cc3 100644 --- a/src/main/events/user-preferences/auto-launch.ts +++ b/src/main/events/user-preferences/auto-launch.ts @@ -3,6 +3,7 @@ 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"), @@ -24,13 +25,17 @@ const autoLaunch = async ( }); if (enabled) { - appLauncher.enable().catch(() => {}); + appLauncher.enable().catch((err) => { + logger.error(err); + }); } else { if (process.platform == "win32") { fs.rm(path.join(windowsStartupPath, "Hydra.vbs"), () => {}); } - appLauncher.disable().catch(() => {}); + appLauncher.disable().catch((err) => { + logger.error(err); + }); } }; From b09f2c055f2f944b94812a191f4249d99be897e6 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:59:20 -0300 Subject: [PATCH 04/10] feat: creating notification for update available --- src/locales/en/translation.json | 4 ++- .../events/autoupdater/check-for-updates.ts | 10 ++++++- src/main/services/notifications.ts | 26 ++++++++++++++++--- .../game-details/modals/repacks-modal.tsx | 5 +++- 4 files changed, 38 insertions(+), 7 deletions(-) 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(() => { From d2b3017de98274bc79dd47bf412fb84c9125c1e5 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:10:19 -0300 Subject: [PATCH 05/10] feat: show notification only when update is ready to install --- src/locales/en/translation.json | 4 ++-- src/locales/pt/translation.json | 4 +++- src/main/events/autoupdater/check-for-updates.ts | 8 +------- src/main/services/notifications.ts | 15 ++------------- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 69c09278..a884ecc2 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -200,8 +200,8 @@ "repack_list_updated": "Repack list updated", "repack_count_one": "{{count}} repack added", "repack_count_other": "{{count}} repacks added", - "new_version_title": "New Hydra version available", - "new_version_body": "Restart Hydra to install the new version" + "new_version_available": "New Hydra version available", + "restart_to_install_new_version": "Restart Hydra to install the new version" }, "system_tray": { "open": "Open Hydra", diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index 4e8a9158..e91ab6a7 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_version_available": "Nova versão do Hydra disponível", + "restart_to_install_new_version": "Reinicie o Hydra para instalar a nova versão" }, "system_tray": { "open": "Abrir Hydra", diff --git a/src/main/events/autoupdater/check-for-updates.ts b/src/main/events/autoupdater/check-for-updates.ts index 30e7a7db..e0a7eb8d 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -3,10 +3,7 @@ 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"; +import { publishNotificationUpdateReadyToInstall } from "@main/services/notifications"; const { autoUpdater } = updater; @@ -28,9 +25,6 @@ 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" }); diff --git a/src/main/services/notifications.ts b/src/main/services/notifications.ts index 2fb3c5da..4e2340fb 100644 --- a/src/main/services/notifications.ts +++ b/src/main/services/notifications.ts @@ -69,21 +69,10 @@ export const publishNewRepacksNotifications = async (count: number) => { export const publishNotificationUpdateReadyToInstall = async () => { new Notification({ - title: t("new_version_title", { + title: t("new_version_available", { 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", { + body: t("restart_to_install_new_version", { ns: "notifications", }), }).show(); From b58330ed354906ab674614211a2a9313bdc5e067 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:13:47 -0300 Subject: [PATCH 06/10] feat: undo change --- src/renderer/src/pages/game-details/modals/repacks-modal.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 3ce87818..c1a2193b 100644 --- a/src/renderer/src/pages/game-details/modals/repacks-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/repacks-modal.tsx @@ -46,9 +46,7 @@ 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(() => { From c24523e8e66185990e4dfdc6a390e653bd271f1c Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:18:37 -0300 Subject: [PATCH 07/10] feat: update i18n --- src/locales/en/translation.json | 4 ++-- src/locales/pt/translation.json | 4 ++-- src/main/services/notifications.ts | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index a884ecc2..e6dc6b50 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -200,8 +200,8 @@ "repack_list_updated": "Repack list updated", "repack_count_one": "{{count}} repack added", "repack_count_other": "{{count}} repacks added", - "new_version_available": "New Hydra version available", - "restart_to_install_new_version": "Restart Hydra to install the new version" + "new_update_available": "New update available", + "restart_to_install_update": "Restart Hydra to install the update" }, "system_tray": { "open": "Open Hydra", diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index e91ab6a7..aa03b0f1 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -196,8 +196,8 @@ "repack_list_updated": "Lista de repacks atualizada", "repack_count_one": "{{count}} novo repack", "repack_count_other": "{{count}} novos repacks", - "new_version_available": "Nova versão do Hydra disponível", - "restart_to_install_new_version": "Reinicie o Hydra para instalar a nova versão" + "new_update_available": "Nova versão disponível", + "restart_to_install_update": "Reinicie o Hydra para instalar a nova versão" }, "system_tray": { "open": "Abrir Hydra", diff --git a/src/main/services/notifications.ts b/src/main/services/notifications.ts index 4e2340fb..5a487f9f 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"; @@ -69,11 +69,12 @@ export const publishNewRepacksNotifications = async (count: number) => { export const publishNotificationUpdateReadyToInstall = async () => { new Notification({ - title: t("new_version_available", { + title: t("new_update_available", { ns: "notifications", }), - body: t("restart_to_install_new_version", { + body: t("restart_to_install_update", { ns: "notifications", }), + icon: trayIcon, }).show(); }; From 9e7b27afe60b7545c2151d08839565986c578bba Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:22:13 -0300 Subject: [PATCH 08/10] feat: undo change --- src/renderer/src/pages/game-details/modals/repacks-modal.tsx | 1 - 1 file changed, 1 deletion(-) 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 c1a2193b..d2d8f5d9 100644 --- a/src/renderer/src/pages/game-details/modals/repacks-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/repacks-modal.tsx @@ -45,7 +45,6 @@ export function RepacksModal({ const getInfoHash = useCallback(async () => { const torrent = await parseTorrent(game?.uri ?? ""); - if (torrent.infoHash) setInfoHash(torrent.infoHash); }, [game]); From b7f94102da4537a44b50f471aca94604443e296c Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:30:34 -0300 Subject: [PATCH 09/10] feat: add version string to notification --- src/locales/en/translation.json | 2 +- src/locales/es/translation.json | 3 ++- src/locales/pt/translation.json | 2 +- src/locales/ru/translation.json | 3 ++- src/main/events/autoupdater/check-for-updates.ts | 5 ++++- src/main/services/notifications.ts | 5 ++++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index e6dc6b50..e44dc7ea 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -200,7 +200,7 @@ "repack_list_updated": "Repack list updated", "repack_count_one": "{{count}} repack added", "repack_count_other": "{{count}} repacks added", - "new_update_available": "New update available", + "new_update_available": "Version {{version}} available", "restart_to_install_update": "Restart Hydra to install the update" }, "system_tray": { 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 aa03b0f1..f1a4e77e 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -196,7 +196,7 @@ "repack_list_updated": "Lista de repacks atualizada", "repack_count_one": "{{count}} novo repack", "repack_count_other": "{{count}} novos repacks", - "new_update_available": "Nova versão disponível", + "new_update_available": "Versão {{version}} disponível", "restart_to_install_update": "Reinicie o Hydra para instalar a nova versão" }, "system_tray": { 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 e0a7eb8d..6c8d3cb0 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -21,14 +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(); + publishNotificationUpdateReadyToInstall(newVersionInfo.version); }); if (app.isPackaged) { diff --git a/src/main/services/notifications.ts b/src/main/services/notifications.ts index 5a487f9f..274ffc91 100644 --- a/src/main/services/notifications.ts +++ b/src/main/services/notifications.ts @@ -67,10 +67,13 @@ export const publishNewRepacksNotifications = async (count: number) => { } }; -export const publishNotificationUpdateReadyToInstall = async () => { +export const publishNotificationUpdateReadyToInstall = async ( + version: string +) => { new Notification({ title: t("new_update_available", { ns: "notifications", + version, }), body: t("restart_to_install_update", { ns: "notifications", From ab81e2134112e0fde84489ab172d2908c68f4d77 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:38:53 -0300 Subject: [PATCH 10/10] feat: update font size --- src/renderer/src/components/header/auto-update-sub-header.tsx | 4 ---- src/renderer/src/components/header/header.css.ts | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) 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 3d3cb18f..038d2a9d 100644 --- a/src/renderer/src/components/header/auto-update-sub-header.tsx +++ b/src/renderer/src/components/header/auto-update-sub-header.tsx @@ -48,9 +48,7 @@ export function AutoUpdateSubHeader() {
- {t("version_available_download", { version: newVersion })} -
); @@ -65,9 +63,7 @@ export function AutoUpdateSubHeader() { 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 c93a8fe9..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,7 +169,7 @@ export const newVersionLink = style({ alignItems: "center", gap: `${SPACING_UNIT}px`, color: "#8e919b", - fontSize: "13px", + fontSize: "12px", }); export const newVersionIcon = style({