fix: fixing typechecks

This commit is contained in:
Hydra
2024-04-25 20:54:38 +01:00
parent b833e7e351
commit 4b57ea48e8
21 changed files with 311 additions and 90 deletions

View File

@@ -9,7 +9,7 @@ const steamGames = stateManager.getValue("steamGames");
const getGames = async (
_event: Electron.IpcMainInvokeEvent,
take?: number,
take = 12,
cursor = 0
): Promise<{ results: CatalogueEntry[]; cursor: number }> => {
const results: CatalogueEntry[] = [];

View File

@@ -6,7 +6,7 @@ import { registerEvent } from "../register-event";
import { searchGames, searchRepacks } from "../helpers/search-games";
import { formatName } from "@main/helpers";
const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
const getRandomGame = async () => {
return getRandomSteam250List().then(async (games) => {
const shuffledList = shuffle(games);

View File

@@ -25,7 +25,6 @@ import "./torrenting/cancel-game-download";
import "./torrenting/pause-game-download";
import "./torrenting/resume-game-download";
import "./torrenting/start-game-download";
import "./torrenting/remove-game-from-download";
import "./user-preferences/get-user-preferences";
import "./user-preferences/update-user-preferences";

View File

@@ -1,10 +1,24 @@
import { registerEvent } from "../register-event";
import { gameRepository } from "../../repository";
import { GameStatus } from "@main/constants";
const removeGame = async (
_event: Electron.IpcMainInvokeEvent,
gameId: number
) => gameRepository.delete({ id: gameId });
) => {
await gameRepository.update(
{
id: gameId,
status: GameStatus.Cancelled,
},
{
status: null,
downloadPath: null,
bytesDownloaded: 0,
progress: 0,
}
);
};
registerEvent(removeGame, {
name: "removeGame",

View File

@@ -42,7 +42,7 @@ const cancelGameDownload = async (
game.status !== GameStatus.Seeding
) {
writePipe.write({ action: "cancel" });
if (result.affected) WindowManager.mainWindow.setProgressBar(-1);
if (result.affected) WindowManager.mainWindow?.setProgressBar(-1);
}
});
};

View File

@@ -24,7 +24,7 @@ const pauseGameDownload = async (
.then((result) => {
if (result.affected) {
writePipe.write({ action: "pause" });
WindowManager.mainWindow.setProgressBar(-1);
WindowManager.mainWindow?.setProgressBar(-1);
}
});
};

View File

@@ -1,34 +0,0 @@
import { GameStatus } from "@main/constants";
import { gameRepository } from "@main/repository";
import { registerEvent } from "../register-event";
const removeGameFromDownload = async (
_event: Electron.IpcMainInvokeEvent,
gameId: number
) => {
const game = await gameRepository.findOne({
where: {
id: gameId,
status: GameStatus.Cancelled,
},
});
if (!game) return;
gameRepository.update(
{
id: game.id,
},
{
status: null,
downloadPath: null,
bytesDownloaded: 0,
progress: 0,
}
);
};
registerEvent(removeGameFromDownload, {
name: "removeGameFromDownload",
});

View File

@@ -1,7 +1,7 @@
import { userPreferencesRepository } from "@main/repository";
import { registerEvent } from "../register-event";
const getUserPreferences = async (_event: Electron.IpcMainInvokeEvent) =>
const getUserPreferences = async () =>
userPreferencesRepository.findOne({
where: { id: 1 },
});