diff --git a/src/globals.ts b/src/globals.ts
index e4675aa7..b240172a 100644
--- a/src/globals.ts
+++ b/src/globals.ts
@@ -7,4 +7,20 @@ export enum GameStatus {
Cancelled = "cancelled",
Finished = "finished",
Decompressing = "decompressing",
+}
+
+export namespace GameStatus {
+ export const isDownloading = (status: GameStatus | "") =>
+ status === GameStatus.Downloading ||
+ status === GameStatus.DownloadingMetadata ||
+ status === GameStatus.CheckingFiles;
+
+ export const isVerifying = (status: GameStatus | "") =>
+ GameStatus.DownloadingMetadata == status ||
+ GameStatus.CheckingFiles == status ||
+ GameStatus.Decompressing == status;
+
+ export const isReady = (status: GameStatus | "") =>
+ status === GameStatus.Finished ||
+ status === GameStatus.Seeding;
}
\ No newline at end of file
diff --git a/src/main/events/torrenting/cancel-game-download.ts b/src/main/events/torrenting/cancel-game-download.ts
index 32aa79ae..af8ae89f 100644
--- a/src/main/events/torrenting/cancel-game-download.ts
+++ b/src/main/events/torrenting/cancel-game-download.ts
@@ -20,6 +20,8 @@ const cancelGameDownload = async (
GameStatus.CheckingFiles,
GameStatus.Paused,
GameStatus.Seeding,
+ GameStatus.Finished,
+ GameStatus.Decompressing,
]),
},
});
diff --git a/src/renderer/components/bottom-panel/bottom-panel.tsx b/src/renderer/components/bottom-panel/bottom-panel.tsx
index c870823e..46e278ca 100644
--- a/src/renderer/components/bottom-panel/bottom-panel.tsx
+++ b/src/renderer/components/bottom-panel/bottom-panel.tsx
@@ -7,6 +7,7 @@ import { vars } from "@renderer/theme.css";
import { useEffect, useMemo, useState } from "react";
import { useNavigate } from "react-router-dom";
import { VERSION_CODENAME } from "@renderer/constants";
+import { GameStatus } from "@globals";
export function BottomPanel() {
const { t } = useTranslation("bottom_panel");
@@ -23,10 +24,10 @@ export function BottomPanel() {
const status = useMemo(() => {
if (isDownloading) {
- if (game.status === "downloading_metadata")
+ if (game.status === GameStatus.DownloadingMetadata)
return t("downloading_metadata", { title: game.title });
- if (game.status === "checking_files")
+ if (game.status === GameStatus.CheckingFiles)
return t("checking_files", {
title: game.title,
percentage: progress,
diff --git a/src/renderer/components/sidebar/sidebar.tsx b/src/renderer/components/sidebar/sidebar.tsx
index 2d853553..cd4aff92 100644
--- a/src/renderer/components/sidebar/sidebar.tsx
+++ b/src/renderer/components/sidebar/sidebar.tsx
@@ -14,6 +14,7 @@ import { MarkGithubIcon } from "@primer/octicons-react";
import DiscordLogo from "@renderer/assets/discord-icon.svg";
import XLogo from "@renderer/assets/x-icon.svg";
import * as styles from "./sidebar.css";
+import { GameStatus } from "@globals";
const socials = [
{
@@ -57,9 +58,7 @@ export function Sidebar() {
}, [gameDownloading?.id, updateLibrary]);
const isDownloading = library.some((game) =>
- ["downloading", "checking_files", "downloading_metadata"].includes(
- game.status
- )
+ GameStatus.isDownloading(game.status)
);
const sidebarRef = useRef
{t(gameDownloading?.status)}
{eta && {t("eta", { eta })}} @@ -112,7 +113,7 @@ export function HeroPanel({ ); } - if (game?.status === "paused") { + if (game?.status === GameStatus.Paused) { return ( <>@@ -127,7 +128,7 @@ export function HeroPanel({ ); } - if (game?.status === "seeding" || (game && !game.status)) { + if (GameStatus.isReady(game?.status) || (game && !game.status)) { if (!game.lastTimePlayed) { return
{t("not_played_yet", { title: game.title })}
; }