mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: refactor
This commit is contained in:
parent
b8bd786c45
commit
aa253466a3
12 changed files with 19 additions and 19 deletions
|
@ -28,7 +28,7 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||
|
||||
await Promise.all([
|
||||
databaseOperations,
|
||||
HydraApi.post("/auth/logout").catch(),
|
||||
HydraApi.post("/auth/logout").catch(() => {}),
|
||||
]);
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import "./library/open-game-installer-path";
|
|||
import "./library/update-executable-path";
|
||||
import "./library/remove-game";
|
||||
import "./library/remove-game-from-library";
|
||||
import "./misc/is-user-logged-in";
|
||||
import "./misc/open-external";
|
||||
import "./misc/show-open-dialog";
|
||||
import "./torrenting/cancel-game-download";
|
||||
|
|
|
@ -20,7 +20,7 @@ const removeRemoveGameFromLibrary = async (gameId: number) => {
|
|||
const game = await gameRepository.findOne({ where: { id: gameId } });
|
||||
|
||||
if (game?.remoteId) {
|
||||
HydraApi.delete(`/games/${game.remoteId}`).catch();
|
||||
HydraApi.delete(`/games/${game.remoteId}`).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { registerEvent } from "../register-event";
|
||||
import * as Sentry from "@sentry/electron/main";
|
||||
import { HydraApi } from "@main/services";
|
||||
import { UserNotLoggedInError, UserProfile } from "@types";
|
||||
import { UserProfile } from "@types";
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { UserNotLoggedInError } from "@shared";
|
||||
|
||||
const getMe = async (
|
||||
_event: Electron.IpcMainInvokeEvent
|
||||
|
|
|
@ -23,14 +23,14 @@ const autoLaunch = async (
|
|||
|
||||
fs.copyFileSync(scriptPath, destination);
|
||||
} else {
|
||||
appLauncher.disable().catch();
|
||||
appLauncher.disable().catch(() => {});
|
||||
fs.rmSync(destination);
|
||||
}
|
||||
} else {
|
||||
if (enabled) {
|
||||
appLauncher.enable().catch();
|
||||
appLauncher.enable().catch(() => {});
|
||||
} else {
|
||||
appLauncher.disable().catch();
|
||||
appLauncher.disable().catch(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ import url from "url";
|
|||
import { uploadGamesBatch } from "./library-sync";
|
||||
import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
|
||||
import { logger } from "./logger";
|
||||
import { UserNotLoggedInError } from "@types";
|
||||
import { UserNotLoggedInError } from "@shared";
|
||||
|
||||
export class HydraApi {
|
||||
private static instance: AxiosInstance;
|
||||
|
|
|
@ -21,5 +21,5 @@ export const createGame = async (game: Game) => {
|
|||
{ remoteId, playTimeInMilliseconds, lastTimePlayed }
|
||||
);
|
||||
})
|
||||
.catch();
|
||||
.catch(() => {});
|
||||
};
|
||||
|
|
|
@ -60,5 +60,5 @@ export const mergeWithRemoteGames = async () => {
|
|||
}
|
||||
}
|
||||
})
|
||||
.catch();
|
||||
.catch(() => {});
|
||||
};
|
||||
|
|
|
@ -9,5 +9,5 @@ export const updateGamePlaytime = async (
|
|||
HydraApi.put(`/games/${game.remoteId}`, {
|
||||
playTimeDeltaInSeconds: Math.trunc(deltaInMillis / 1000),
|
||||
lastTimePlayed,
|
||||
}).catch();
|
||||
}).catch(() => {});
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ export const uploadGamesBatch = async () => {
|
|||
lastTimePlayed: game.lastTimePlayed,
|
||||
};
|
||||
})
|
||||
).catch();
|
||||
).catch(() => {});
|
||||
}
|
||||
|
||||
await mergeWithRemoteGames();
|
||||
|
|
|
@ -8,6 +8,13 @@ export enum DownloadSourceStatus {
|
|||
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"];
|
||||
|
||||
export const formatBytes = (bytes: number): string => {
|
||||
|
|
|
@ -290,10 +290,3 @@ export interface DownloadSource {
|
|||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export class UserNotLoggedInError extends Error {
|
||||
constructor() {
|
||||
super("user not logged in");
|
||||
this.name = "UserNotLoggedInError";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue