mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 11:42:21 +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",
|
"game_ready_to_install": "{{title}} is ready to install",
|
||||||
"repack_list_updated": "Repack list updated",
|
"repack_list_updated": "Repack list updated",
|
||||||
"repack_count_one": "{{count}} repack added",
|
"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": {
|
"system_tray": {
|
||||||
"open": "Open Hydra",
|
"open": "Open Hydra",
|
||||||
|
@ -3,6 +3,10 @@ import { registerEvent } from "../register-event";
|
|||||||
import updater, { UpdateInfo } from "electron-updater";
|
import updater, { UpdateInfo } from "electron-updater";
|
||||||
import { WindowManager } from "@main/services";
|
import { WindowManager } from "@main/services";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
|
import {
|
||||||
|
publishNotificationUpdateAvailable,
|
||||||
|
publishNotificationUpdateReadyToInstall,
|
||||||
|
} from "@main/services/notifications";
|
||||||
|
|
||||||
const { autoUpdater } = updater;
|
const { autoUpdater } = updater;
|
||||||
|
|
||||||
@ -24,14 +28,18 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||||||
autoUpdater
|
autoUpdater
|
||||||
.once("update-available", (info: UpdateInfo) => {
|
.once("update-available", (info: UpdateInfo) => {
|
||||||
sendEvent({ type: "update-available", info });
|
sendEvent({ type: "update-available", info });
|
||||||
|
if (!isAutoInstallAvailable) {
|
||||||
|
publishNotificationUpdateAvailable();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.once("update-downloaded", () => {
|
.once("update-downloaded", () => {
|
||||||
sendEvent({ type: "update-downloaded" });
|
sendEvent({ type: "update-downloaded" });
|
||||||
|
publishNotificationUpdateReadyToInstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
autoUpdater.autoDownload = isAutoInstallAvailable;
|
autoUpdater.autoDownload = isAutoInstallAvailable;
|
||||||
autoUpdater.checkForUpdatesAndNotify();
|
autoUpdater.checkForUpdates();
|
||||||
} else if (sendEventsForDebug) {
|
} else if (sendEventsForDebug) {
|
||||||
mockValuesForDebug();
|
mockValuesForDebug();
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,9 @@ export const publishDownloadCompleteNotification = async (game: Game) => {
|
|||||||
new Notification({
|
new Notification({
|
||||||
title: t("download_complete", {
|
title: t("download_complete", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences.language,
|
|
||||||
}),
|
}),
|
||||||
body: t("game_ready_to_install", {
|
body: t("game_ready_to_install", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences.language,
|
|
||||||
title: game.title,
|
title: game.title,
|
||||||
}),
|
}),
|
||||||
icon,
|
icon,
|
||||||
@ -60,13 +58,33 @@ export const publishNewRepacksNotifications = async (count: number) => {
|
|||||||
new Notification({
|
new Notification({
|
||||||
title: t("repack_list_updated", {
|
title: t("repack_list_updated", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences?.language || "en",
|
|
||||||
}),
|
}),
|
||||||
body: t("repack_count", {
|
body: t("repack_count", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences?.language || "en",
|
|
||||||
count: count,
|
count: count,
|
||||||
}),
|
}),
|
||||||
}).show();
|
}).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 getInfoHash = useCallback(async () => {
|
||||||
const torrent = await parseTorrent(game?.uri ?? "");
|
const torrent = await parseTorrent(game?.uri ?? "");
|
||||||
if (torrent.infoHash) setInfoHash(torrent.infoHash);
|
|
||||||
|
if (torrent.infoHash) {
|
||||||
|
setInfoHash(torrent.infoHash);
|
||||||
|
}
|
||||||
}, [game]);
|
}, [game]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user