mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-25 11:51:02 +00:00
Merge branch 'main' of https://github.com/hydralauncher/hydra
This commit is contained in:
@@ -11,6 +11,9 @@ import { HTTPDownloader } from "./http-downloader";
|
||||
import { Unrar } from "../unrar";
|
||||
import { GameStatus } from "@globals";
|
||||
import path from "node:path";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
|
||||
|
||||
interface DownloadStatus {
|
||||
numPeers: number;
|
||||
@@ -112,7 +115,7 @@ export class Downloader {
|
||||
});
|
||||
|
||||
if (
|
||||
gameUpdate.progress === 1 &&
|
||||
game?.progress === 1 &&
|
||||
gameUpdate.status !== GameStatus.Decompressing
|
||||
) {
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
@@ -120,7 +123,10 @@ export class Downloader {
|
||||
});
|
||||
|
||||
if (userPreferences?.downloadNotificationsEnabled) {
|
||||
const iconPath = await this.createTempIcon(game.iconUrl);
|
||||
|
||||
new Notification({
|
||||
icon: iconPath,
|
||||
title: t("download_complete", {
|
||||
ns: "notifications",
|
||||
lng: userPreferences.language,
|
||||
@@ -186,4 +192,23 @@ export class Downloader {
|
||||
return game.decompressionProgress;
|
||||
return game.progress;
|
||||
}
|
||||
|
||||
private static createTempIcon(encodedIcon: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const hash = crypto.randomBytes(16).toString("hex");
|
||||
const iconPath = path.join(app.getPath("temp"), `${hash}.png`);
|
||||
|
||||
fs.writeFile(
|
||||
iconPath,
|
||||
Buffer.from(
|
||||
encodedIcon.replace("data:image/jpeg;base64,", ""),
|
||||
"base64"
|
||||
),
|
||||
(err) => {
|
||||
if (err) reject(err);
|
||||
resolve(iconPath);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ export const startProcessWatcher = async () => {
|
||||
});
|
||||
|
||||
if (games.length === 0) {
|
||||
await sleep(sleepTime);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ const getXatabRepack = (url: string) => {
|
||||
worker.removeListener("message", onMessage);
|
||||
};
|
||||
|
||||
worker.on("message", onMessage);
|
||||
worker.postMessage($downloadButton.href);
|
||||
worker.once("message", onMessage);
|
||||
})();
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user