fix: possible undefined on bottom-panel

This commit is contained in:
Zamitto 2025-02-02 20:53:31 -03:00
parent 6d1c8d165a
commit d1a1d3fc32
4 changed files with 549 additions and 80 deletions

View file

@ -234,9 +234,9 @@ export class DownloadManager {
});
WindowManager.mainWindow?.setProgressBar(-1);
WindowManager.mainWindow?.webContents.send("on-download-progress", null);
if (downloadKey === this.downloadingGameId) {
WindowManager.mainWindow?.webContents.send("on-download-progress", null);
this.downloadingGameId = null;
}
}

View file

@ -19,8 +19,6 @@ export function BottomPanel() {
const { lastPacket, progress, downloadSpeed, eta } = useDownload();
const isGameDownloading = !!lastPacket;
const [version, setVersion] = useState("");
const [sessionHash, setSessionHash] = useState<null | string>("");
@ -33,9 +31,11 @@ export function BottomPanel() {
}, [userDetails?.id]);
const status = useMemo(() => {
if (isGameDownloading) {
const game = library.find((game) => game.id === lastPacket?.gameId)!;
const game = lastPacket
? library.find((game) => game.id === lastPacket?.gameId)
: undefined;
if (game) {
if (lastPacket?.isCheckingFiles)
return t("checking_files", {
title: game.title,
@ -64,7 +64,7 @@ export function BottomPanel() {
}
return t("no_downloads_in_progress");
}, [t, isGameDownloading, library, lastPacket, progress, eta, downloadSpeed]);
}, [t, library, lastPacket, progress, eta, downloadSpeed]);
return (
<footer className="bottom-panel">