diff --git a/src/main/entity/game.entity.ts b/src/main/entity/game.entity.ts index 8798a15d..60daeb64 100644 --- a/src/main/entity/game.entity.ts +++ b/src/main/entity/game.entity.ts @@ -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; diff --git a/src/main/entity/user-preferences.entity.ts b/src/main/entity/user-preferences.entity.ts index 40f1a26a..8cb06aa5 100644 --- a/src/main/entity/user-preferences.entity.ts +++ b/src/main/entity/user-preferences.entity.ts @@ -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; } + diff --git a/src/renderer/hooks/use-download.ts b/src/renderer/hooks/use-download.ts index 0c649229..861a0591 100644 --- a/src/renderer/hooks/use-download.ts +++ b/src/renderer/hooks/use-download.ts @@ -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)); diff --git a/src/renderer/pages/settings/settings.tsx b/src/renderer/pages/settings/settings.tsx index 47bd604b..23451b35 100644 --- a/src/renderer/pages/settings/settings.tsx +++ b/src/renderer/pages/settings/settings.tsx @@ -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) } /> + + { + updateUserPreferences("realDebridApiToken", event.target.value); + }} + /> ); diff --git a/src/types/index.ts b/src/types/index.ts index d9070451..a8071a6f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -84,6 +84,7 @@ export interface Game extends Omit { 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 {