mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: creating notification for update available
This commit is contained in:
parent
4be3db8007
commit
b09f2c055f
@ -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",
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user