fix: adding bit validation to is deleted

This commit is contained in:
Chubby Granny Chaser 2025-01-22 09:43:28 +00:00
parent f5532fa26f
commit 4c5c602775
No known key found for this signature in database
8 changed files with 23 additions and 23 deletions

View file

@ -14,7 +14,7 @@ const pauseGameDownload = async (
const download = await downloadsSublevel.get(gameKey); const download = await downloadsSublevel.get(gameKey);
if (download) { if (download) {
await DownloadManager.pauseDownload(); await DownloadManager.pauseDownload(gameKey);
await downloadsSublevel.put(gameKey, { await downloadsSublevel.put(gameKey, {
...download, ...download,

View file

@ -86,7 +86,7 @@ const migrateFromSqlite = async () => {
playTimeInMilliseconds: game.playTimeInMilliseconds, playTimeInMilliseconds: game.playTimeInMilliseconds,
lastTimePlayed: game.lastTimePlayed, lastTimePlayed: game.lastTimePlayed,
remoteId: game.remoteId, remoteId: game.remoteId,
isDeleted: game.isDeleted, isDeleted: game.isDeleted === 1,
}, },
})) }))
); );

View file

@ -207,11 +207,11 @@ export class DownloadManager {
WindowManager.mainWindow?.webContents.send("on-seeding-status", seedStatus); WindowManager.mainWindow?.webContents.send("on-seeding-status", seedStatus);
} }
static async pauseDownload() { static async pauseDownload(downloadKey = this.downloadingGameId) {
await PythonRPC.rpc await PythonRPC.rpc
.post("/action", { .post("/action", {
action: "pause", action: "pause",
game_id: this.downloadingGameId, game_id: downloadKey,
} as PauseDownloadPayload) } as PauseDownloadPayload)
.catch(() => {}); .catch(() => {});

View file

@ -190,12 +190,12 @@ export const watchProcesses = async () => {
const hasProcess = processMap.get(executable)?.has(executablePath); const hasProcess = processMap.get(executable)?.has(executablePath);
if (hasProcess) { if (hasProcess) {
if (gamesPlaytime.has(`${game.shop}-${game.objectId}`)) { if (gamesPlaytime.has(levelKeys.game(game.shop, game.objectId))) {
onTickGame(game); onTickGame(game);
} else { } else {
onOpenGame(game); onOpenGame(game);
} }
} else if (gamesPlaytime.has(`${game.shop}-${game.objectId}`)) { } else if (gamesPlaytime.has(levelKeys.game(game.shop, game.objectId))) {
onCloseGame(game); onCloseGame(game);
} }
} }
@ -207,20 +207,17 @@ export const watchProcesses = async () => {
return { return {
id: entry[0], id: entry[0],
sessionDurationInMillis: performance.now() - entry[1].firstTick, sessionDurationInMillis: performance.now() - entry[1].firstTick,
}; } as Pick<GameRunning, "id" | "sessionDurationInMillis">;
}); });
WindowManager.mainWindow.webContents.send( WindowManager.mainWindow.webContents.send("on-games-running", gamesRunning);
"on-games-running",
gamesRunning as Pick<GameRunning, "id" | "sessionDurationInMillis">[]
);
} }
}; };
function onOpenGame(game: Game) { function onOpenGame(game: Game) {
const now = performance.now(); const now = performance.now();
gamesPlaytime.set(`${game.shop}-${game.objectId}`, { gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
lastTick: now, lastTick: now,
firstTick: now, firstTick: now,
lastSyncTick: now, lastSyncTick: now,
@ -235,7 +232,9 @@ function onOpenGame(game: Game) {
function onTickGame(game: Game) { function onTickGame(game: Game) {
const now = performance.now(); const now = performance.now();
const gamePlaytime = gamesPlaytime.get(`${game.shop}-${game.objectId}`)!; const gamePlaytime = gamesPlaytime.get(
levelKeys.game(game.shop, game.objectId)
)!;
const delta = now - gamePlaytime.lastTick; const delta = now - gamePlaytime.lastTick;
@ -251,7 +250,7 @@ function onTickGame(game: Game) {
lastTimePlayed: new Date(), lastTimePlayed: new Date(),
}); });
gamesPlaytime.set(`${game.shop}-${game.objectId}`, { gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
...gamePlaytime, ...gamePlaytime,
lastTick: now, lastTick: now,
}); });
@ -267,7 +266,7 @@ function onTickGame(game: Game) {
gamePromise gamePromise
.then(() => { .then(() => {
gamesPlaytime.set(`${game.shop}-${game.objectId}`, { gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
...gamePlaytime, ...gamePlaytime,
lastSyncTick: now, lastSyncTick: now,
}); });
@ -277,8 +276,10 @@ function onTickGame(game: Game) {
} }
const onCloseGame = (game: Game) => { const onCloseGame = (game: Game) => {
const gamePlaytime = gamesPlaytime.get(`${game.shop}-${game.objectId}`)!; const gamePlaytime = gamesPlaytime.get(
gamesPlaytime.delete(`${game.shop}-${game.objectId}`); levelKeys.game(game.shop, game.objectId)
)!;
gamesPlaytime.delete(levelKeys.game(game.shop, game.objectId));
if (game.remoteId) { if (game.remoteId) {
updateGamePlaytime( updateGamePlaytime(

View file

@ -10,7 +10,7 @@ const initialState: GameRunningState = {
}; };
export const gameRunningSlice = createSlice({ export const gameRunningSlice = createSlice({
name: "running-game", name: "game-running",
initialState, initialState,
reducers: { reducers: {
setGameRunning: (state, action: PayloadAction<GameRunning | null>) => { setGameRunning: (state, action: PayloadAction<GameRunning | null>) => {

View file

@ -4,7 +4,7 @@ export * from "./download-slice";
export * from "./window-slice"; export * from "./window-slice";
export * from "./toast-slice"; export * from "./toast-slice";
export * from "./user-details-slice"; export * from "./user-details-slice";
export * from "./running-game-slice"; export * from "./game-running.slice";
export * from "./subscription-slice"; export * from "./subscription-slice";
export * from "./repacks-slice"; export * from "./repacks-slice";
export * from "./catalogue-search"; export * from "./catalogue-search";

View file

@ -71,8 +71,8 @@ export function DownloadGroup({
if (download.fileSize) return formatBytes(download.fileSize); if (download.fileSize) return formatBytes(download.fileSize);
if (download.fileSize && isGameDownloading) if (lastPacket?.download.fileSize && isGameDownloading)
return formatBytes(download?.fileSize); return formatBytes(lastPacket.download.fileSize);
return "N/A"; return "N/A";
}; };
@ -90,8 +90,6 @@ export function DownloadGroup({
const getGameInfo = (game: LibraryGame) => { const getGameInfo = (game: LibraryGame) => {
const download = game.download!; const download = game.download!;
console.log(game);
const isGameDownloading = lastPacket?.gameId === game.id; const isGameDownloading = lastPacket?.gameId === game.id;
const finalDownloadSize = getFinalDownloadSize(game); const finalDownloadSize = getFinalDownloadSize(game);
const seedingStatus = seedingMap.get(game.id); const seedingStatus = seedingMap.get(game.id);

View file

@ -45,6 +45,7 @@ export interface UserGame {
} }
export interface GameRunning { export interface GameRunning {
id: string;
title: string; title: string;
iconUrl: string | null; iconUrl: string | null;
objectId: string; objectId: string;