feat: refactor

This commit is contained in:
Zamitto 2024-07-02 23:31:07 -03:00
parent b8bd786c45
commit aa253466a3
12 changed files with 19 additions and 19 deletions

View file

@ -28,7 +28,7 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
await Promise.all([ await Promise.all([
databaseOperations, databaseOperations,
HydraApi.post("/auth/logout").catch(), HydraApi.post("/auth/logout").catch(() => {}),
]); ]);
}; };

View file

@ -22,7 +22,6 @@ import "./library/open-game-installer-path";
import "./library/update-executable-path"; import "./library/update-executable-path";
import "./library/remove-game"; import "./library/remove-game";
import "./library/remove-game-from-library"; import "./library/remove-game-from-library";
import "./misc/is-user-logged-in";
import "./misc/open-external"; import "./misc/open-external";
import "./misc/show-open-dialog"; import "./misc/show-open-dialog";
import "./torrenting/cancel-game-download"; import "./torrenting/cancel-game-download";

View file

@ -20,7 +20,7 @@ const removeRemoveGameFromLibrary = async (gameId: number) => {
const game = await gameRepository.findOne({ where: { id: gameId } }); const game = await gameRepository.findOne({ where: { id: gameId } });
if (game?.remoteId) { if (game?.remoteId) {
HydraApi.delete(`/games/${game.remoteId}`).catch(); HydraApi.delete(`/games/${game.remoteId}`).catch(() => {});
} }
}; };

View file

@ -1,8 +1,9 @@
import { registerEvent } from "../register-event"; import { registerEvent } from "../register-event";
import * as Sentry from "@sentry/electron/main"; import * as Sentry from "@sentry/electron/main";
import { HydraApi } from "@main/services"; import { HydraApi } from "@main/services";
import { UserNotLoggedInError, UserProfile } from "@types"; import { UserProfile } from "@types";
import { userAuthRepository } from "@main/repository"; import { userAuthRepository } from "@main/repository";
import { UserNotLoggedInError } from "@shared";
const getMe = async ( const getMe = async (
_event: Electron.IpcMainInvokeEvent _event: Electron.IpcMainInvokeEvent

View file

@ -23,14 +23,14 @@ const autoLaunch = async (
fs.copyFileSync(scriptPath, destination); fs.copyFileSync(scriptPath, destination);
} else { } else {
appLauncher.disable().catch(); appLauncher.disable().catch(() => {});
fs.rmSync(destination); fs.rmSync(destination);
} }
} else { } else {
if (enabled) { if (enabled) {
appLauncher.enable().catch(); appLauncher.enable().catch(() => {});
} else { } else {
appLauncher.disable().catch(); appLauncher.disable().catch(() => {});
} }
} }
}; };

View file

@ -5,7 +5,7 @@ import url from "url";
import { uploadGamesBatch } from "./library-sync"; import { uploadGamesBatch } from "./library-sync";
import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id"; import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
import { logger } from "./logger"; import { logger } from "./logger";
import { UserNotLoggedInError } from "@types"; import { UserNotLoggedInError } from "@shared";
export class HydraApi { export class HydraApi {
private static instance: AxiosInstance; private static instance: AxiosInstance;

View file

@ -21,5 +21,5 @@ export const createGame = async (game: Game) => {
{ remoteId, playTimeInMilliseconds, lastTimePlayed } { remoteId, playTimeInMilliseconds, lastTimePlayed }
); );
}) })
.catch(); .catch(() => {});
}; };

View file

@ -60,5 +60,5 @@ export const mergeWithRemoteGames = async () => {
} }
} }
}) })
.catch(); .catch(() => {});
}; };

View file

@ -9,5 +9,5 @@ export const updateGamePlaytime = async (
HydraApi.put(`/games/${game.remoteId}`, { HydraApi.put(`/games/${game.remoteId}`, {
playTimeDeltaInSeconds: Math.trunc(deltaInMillis / 1000), playTimeDeltaInSeconds: Math.trunc(deltaInMillis / 1000),
lastTimePlayed, lastTimePlayed,
}).catch(); }).catch(() => {});
}; };

View file

@ -23,7 +23,7 @@ export const uploadGamesBatch = async () => {
lastTimePlayed: game.lastTimePlayed, lastTimePlayed: game.lastTimePlayed,
}; };
}) })
).catch(); ).catch(() => {});
} }
await mergeWithRemoteGames(); await mergeWithRemoteGames();

View file

@ -8,6 +8,13 @@ export enum DownloadSourceStatus {
Errored, Errored,
} }
export class UserNotLoggedInError extends Error {
constructor() {
super("user not logged in");
this.name = "UserNotLoggedInError";
}
}
const FORMAT = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; const FORMAT = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
export const formatBytes = (bytes: number): string => { export const formatBytes = (bytes: number): string => {

View file

@ -290,10 +290,3 @@ export interface DownloadSource {
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
} }
export class UserNotLoggedInError extends Error {
constructor() {
super("user not logged in");
this.name = "UserNotLoggedInError";
}
}