feat: create game

This commit is contained in:
Zamitto 2024-12-17 13:23:56 -03:00
parent b0bf33191b
commit 3a964dcf17
2 changed files with 14 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { registerEvent } from "../register-event";
import type { StartGameDownloadPayload } from "@types";
import { DownloadManager, HydraApi, logger } from "@main/services";
import { DownloadManager, HydraApi } from "@main/services";
import { Not } from "typeorm";
import { steamGamesWorker } from "@main/workers";
@ -76,8 +76,14 @@ const startGameDownload = async (
},
});
createGame(updatedGame!).catch(() => {});
await DownloadManager.cancelDownload(updatedGame!.id);
await DownloadManager.startDownload(updatedGame!);
await downloadQueueRepository.delete({ game: { id: updatedGame!.id } });
await downloadQueueRepository.insert({ game: { id: updatedGame!.id } });
await Promise.all([
createGame(updatedGame!).catch(() => {}),
HydraApi.post(
"/games/download",
{
@ -85,15 +91,8 @@ const startGameDownload = async (
shop: updatedGame!.shop,
},
{ needsAuth: false }
).catch((err) => {
logger.error("Failed to create game download", err);
});
await DownloadManager.cancelDownload(updatedGame!.id);
await DownloadManager.startDownload(updatedGame!);
await downloadQueueRepository.delete({ game: { id: updatedGame!.id } });
await downloadQueueRepository.insert({ game: { id: updatedGame!.id } });
).catch(() => {}),
]);
});
};

View File

@ -11,10 +11,10 @@ import type {
GameRunning,
FriendRequestAction,
UpdateProfileRequest,
GameAchievement,
} from "@types";
import type { CatalogueCategory } from "@shared";
import type { AxiosProgressEvent } from "axios";
import { GameAchievement } from "@main/entity";
contextBridge.exposeInMainWorld("electron", {
/* Torrenting */