feat: added fields in entities to support rar decompression progress, and real debrid api token settings

This commit is contained in:
lilezek 2024-04-29 20:52:53 +02:00
parent 6fa4c178a7
commit 3ef2f87412
5 changed files with 34 additions and 5 deletions

View File

@ -34,6 +34,9 @@ export class Game {
@Column("text", { nullable: true })
executablePath: string | null;
@Column("text", { nullable: true })
rarPath: string | null;
@Column("int", { default: 0 })
playTimeInMilliseconds: number;
@ -43,12 +46,18 @@ export class Game {
@Column("text", { nullable: true })
status: GameStatus | "";
/**
* Progress is a float between 0 and 1
*/
@Column("float", { default: 0 })
progress: number;
@Column("float", { default: 0 })
fileVerificationProgress: number;
@Column("float", { default: 0 })
decompressionProgress: number;
@Column("int", { default: 0 })
bytesDownloaded: number;

View File

@ -17,6 +17,9 @@ export class UserPreferences {
@Column("text", { default: "en" })
language: string;
@Column("text", { nullable: true })
realDebridApiToken: string | null;
@Column("boolean", { default: false })
downloadNotificationsEnabled: boolean;
@ -32,3 +35,4 @@ export class UserPreferences {
@UpdateDateColumn()
updatedAt: Date;
}

View File

@ -12,6 +12,7 @@ import {
import type { GameShop, TorrentProgress } from "@types";
import { useDate } from "./use-date";
import { formatBytes } from "@renderer/utils";
import { GameStatus } from "@globals";
export function useDownload() {
const { updateLibrary } = useLibrary();
@ -63,9 +64,10 @@ export function useDownload() {
updateLibrary();
});
const isVerifying = ["downloading_metadata", "checking_files"].includes(
lastPacket?.game.status
);
const isVerifying =
GameStatus.DownloadingMetadata == lastPacket?.game.status ||
GameStatus.CheckingFiles == lastPacket?.game.status ||
GameStatus.Decompressing == lastPacket?.game.status;
const getETA = () => {
if (isVerifying || !isFinite(lastPacket?.timeRemaining)) {
@ -84,8 +86,10 @@ export function useDownload() {
};
const getProgress = () => {
if (lastPacket?.game.status === "checking_files") {
if (lastPacket?.game.status === GameStatus.CheckingFiles) {
return formatDownloadProgress(lastPacket?.game.fileVerificationProgress);
} else if (lastPacket?.game.status === GameStatus.Decompressing) {
return formatDownloadProgress(lastPacket?.game.decompressionProgress);
}
return formatDownloadProgress(lastPacket?.game.progress);
@ -98,7 +102,7 @@ export function useDownload() {
dispatch(setGameDeleting(gameId));
return window.electron.deleteGameFolder(gameId);
})
.catch(() => {})
.catch(() => { })
.finally(() => {
updateLibrary();
dispatch(removeGameFromDeleting(gameId));

View File

@ -11,6 +11,7 @@ export function Settings() {
downloadNotificationsEnabled: false,
repackUpdatesNotificationsEnabled: false,
telemetryEnabled: false,
realDebridApiToken: null,
});
const { t } = useTranslation("settings");
@ -27,6 +28,7 @@ export function Settings() {
repackUpdatesNotificationsEnabled:
userPreferences?.repackUpdatesNotificationsEnabled,
telemetryEnabled: userPreferences?.telemetryEnabled,
realDebridApiToken: userPreferences.realDebridApiToken,
});
});
}, []);
@ -107,6 +109,14 @@ export function Settings() {
updateUserPreferences("telemetryEnabled", !form.telemetryEnabled)
}
/>
<TextField
label={t("real_debrid_api_token")}
value={form.realDebridApiToken ?? ""}
onChange={(event) => {
updateUserPreferences("realDebridApiToken", event.target.value);
}}
/>
</div>
</section>
);

View File

@ -84,6 +84,7 @@ export interface Game extends Omit<CatalogueEntry, "cover"> {
repack: GameRepack;
progress: number;
fileVerificationProgress: number;
decompressionProgress: number;
bytesDownloaded: number;
playTimeInMilliseconds: number;
executablePath: string | null;
@ -107,6 +108,7 @@ export interface UserPreferences {
downloadNotificationsEnabled: boolean;
repackUpdatesNotificationsEnabled: boolean;
telemetryEnabled: boolean;
realDebridApiToken: string | null;
}
export interface HowLongToBeatCategory {