mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: fixing typechecks
This commit is contained in:
parent
c07f82ce49
commit
f9223ad36d
21 changed files with 311 additions and 90 deletions
|
@ -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[] = [];
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ const pauseGameDownload = async (
|
|||
.then((result) => {
|
||||
if (result.affected) {
|
||||
writePipe.write({ action: "pause" });
|
||||
WindowManager.mainWindow.setProgressBar(-1);
|
||||
WindowManager.mainWindow?.setProgressBar(-1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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",
|
||||
});
|
|
@ -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 },
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
getNewRepacksFromCPG,
|
||||
getNewRepacksFromUser,
|
||||
// getNewRepacksFromXatab,
|
||||
// getNewRepacksFromOnlineFix,
|
||||
getNewRepacksFromOnlineFix,
|
||||
readPipe,
|
||||
startProcessWatcher,
|
||||
writePipe,
|
||||
|
@ -79,9 +79,9 @@ const checkForNewRepacks = async () => {
|
|||
getNewRepacksFromCPG(
|
||||
existingRepacks.filter((repack) => repack.repacker === "CPG")
|
||||
),
|
||||
// getNewRepacksFromOnlineFix(
|
||||
// existingRepacks.filter((repack) => repack.repacker === "onlinefix")
|
||||
// ),
|
||||
getNewRepacksFromOnlineFix(
|
||||
existingRepacks.filter((repack) => repack.repacker === "onlinefix")
|
||||
),
|
||||
track1337xUsers(existingRepacks),
|
||||
]).then(() => {
|
||||
repackRepository.count().then((count) => {
|
||||
|
|
|
@ -19,17 +19,17 @@ export const getNewRepacksFromCPG = async (
|
|||
try {
|
||||
Array.from(window.document.querySelectorAll(".post")).forEach(($post) => {
|
||||
const $title = $post.querySelector(".entry-title");
|
||||
const uploadDate = $post.querySelector("time").getAttribute("datetime");
|
||||
const uploadDate = $post.querySelector("time")?.getAttribute("datetime");
|
||||
|
||||
const $downloadInfo = Array.from(
|
||||
$post.querySelectorAll(".wp-block-heading")
|
||||
).find(($heading) => $heading.textContent.startsWith("Download"));
|
||||
).find(($heading) => $heading.textContent?.startsWith("Download"));
|
||||
|
||||
/* Side note: CPG often misspells "Magnet" as "Magent" */
|
||||
const $magnet = Array.from($post.querySelectorAll("a")).find(
|
||||
($a) =>
|
||||
$a.textContent.startsWith("Magnet") ||
|
||||
$a.textContent.startsWith("Magent")
|
||||
$a.textContent?.startsWith("Magnet") ||
|
||||
$a.textContent?.startsWith("Magent")
|
||||
);
|
||||
|
||||
const fileSize = $downloadInfo.textContent
|
||||
|
|
|
@ -2,4 +2,4 @@ export * from "./1337x";
|
|||
export * from "./xatab";
|
||||
export * from "./cpg-repacks";
|
||||
export * from "./gog";
|
||||
// export * from "./online-fix";
|
||||
export * from "./online-fix";
|
||||
|
|
|
@ -88,7 +88,7 @@ export const getNewRepacksFromOnlineFix = async (
|
|||
const repacks: GameRepackInput[] = [];
|
||||
const articles = Array.from(document.querySelectorAll(".news"));
|
||||
const totalPages = Number(
|
||||
document.querySelector("nav > a:nth-child(13)").textContent
|
||||
document.querySelector("nav > a:nth-child(13)")?.textContent
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -186,8 +186,10 @@ export const getNewRepacksFromOnlineFix = async (
|
|||
});
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(err.message, { method: "getNewRepacksFromOnlineFix" });
|
||||
} catch (err: unknown) {
|
||||
logger.error((err as Error).message, {
|
||||
method: "getNewRepacksFromOnlineFix",
|
||||
});
|
||||
}
|
||||
|
||||
const newRepacks = repacks.filter(
|
||||
|
|
|
@ -7,17 +7,16 @@ export const requestSteam250 = async (path: string) => {
|
|||
const { window } = new JSDOM(response.data);
|
||||
const { document } = window;
|
||||
|
||||
return Array.from(document.querySelectorAll(".appline .title a")).map(
|
||||
($title: HTMLAnchorElement) => {
|
||||
const steamGameUrl = $title.href;
|
||||
if (!steamGameUrl) return null;
|
||||
return Array.from(document.querySelectorAll(".appline .title a"))
|
||||
.filter(($title) => Boolean(($title as HTMLAnchorElement).href))
|
||||
.map(($title) => {
|
||||
const steamGameUrl = ($title as HTMLAnchorElement).href;
|
||||
|
||||
return {
|
||||
title: $title.textContent,
|
||||
objectID: steamGameUrl.split("/").pop(),
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -12,13 +12,16 @@ export class WindowManager {
|
|||
// HMR for renderer base on electron-vite cli.
|
||||
// Load the remote URL for development or the local html file for production.
|
||||
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
|
||||
this.mainWindow.loadURL(
|
||||
this.mainWindow?.loadURL(
|
||||
`${process.env["ELECTRON_RENDERER_URL"]}#/${hash}`
|
||||
);
|
||||
} else {
|
||||
this.mainWindow.loadFile(path.join(__dirname, "../renderer/index.html"), {
|
||||
hash,
|
||||
});
|
||||
this.mainWindow?.loadFile(
|
||||
path.join(__dirname, "../renderer/index.html"),
|
||||
{
|
||||
hash,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +50,7 @@ export class WindowManager {
|
|||
this.mainWindow.removeMenu();
|
||||
|
||||
this.mainWindow.on("close", () => {
|
||||
WindowManager.mainWindow.setProgressBar(-1);
|
||||
WindowManager.mainWindow?.setProgressBar(-1);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -55,8 +58,8 @@ export class WindowManager {
|
|||
if (!this.mainWindow) this.createMainWindow();
|
||||
this.loadURL(hash);
|
||||
|
||||
if (this.mainWindow.isMinimized()) this.mainWindow.restore();
|
||||
this.mainWindow.focus();
|
||||
if (this.mainWindow?.isMinimized()) this.mainWindow.restore();
|
||||
this.mainWindow?.focus();
|
||||
}
|
||||
|
||||
public static createSystemTray(language: string) {
|
||||
|
@ -93,10 +96,10 @@ export class WindowManager {
|
|||
if (process.platform === "win32") {
|
||||
tray.addListener("click", () => {
|
||||
if (this.mainWindow) {
|
||||
if (WindowManager.mainWindow.isMinimized())
|
||||
if (WindowManager.mainWindow?.isMinimized())
|
||||
WindowManager.mainWindow.restore();
|
||||
|
||||
WindowManager.mainWindow.focus();
|
||||
WindowManager.mainWindow?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
import * as styles from "./app.css";
|
||||
import { themeClass } from "./theme.css";
|
||||
|
||||
import { Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
setSearch,
|
||||
clearSearch,
|
||||
|
|
|
@ -25,3 +25,5 @@ export const AsyncImage = forwardRef<HTMLImageElement, AsyncImageProps>(
|
|||
return <img ref={ref} {...props} src={source ?? props.src} />;
|
||||
}
|
||||
);
|
||||
|
||||
AsyncImage.displayName = "AsyncImage";
|
||||
|
|
|
@ -61,7 +61,7 @@ export function BottomPanel() {
|
|||
</button>
|
||||
|
||||
<small>
|
||||
v{version} "{VERSION_CODENAME}"
|
||||
v{version} "{VERSION_CODENAME}"
|
||||
</small>
|
||||
</footer>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue