mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-22 10:23:56 +00:00
fix: adding bit validation to is deleted
This commit is contained in:
@@ -14,7 +14,7 @@ const pauseGameDownload = async (
|
||||
const download = await downloadsSublevel.get(gameKey);
|
||||
|
||||
if (download) {
|
||||
await DownloadManager.pauseDownload();
|
||||
await DownloadManager.pauseDownload(gameKey);
|
||||
|
||||
await downloadsSublevel.put(gameKey, {
|
||||
...download,
|
||||
|
||||
@@ -86,7 +86,7 @@ const migrateFromSqlite = async () => {
|
||||
playTimeInMilliseconds: game.playTimeInMilliseconds,
|
||||
lastTimePlayed: game.lastTimePlayed,
|
||||
remoteId: game.remoteId,
|
||||
isDeleted: game.isDeleted,
|
||||
isDeleted: game.isDeleted === 1,
|
||||
},
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -207,11 +207,11 @@ export class DownloadManager {
|
||||
WindowManager.mainWindow?.webContents.send("on-seeding-status", seedStatus);
|
||||
}
|
||||
|
||||
static async pauseDownload() {
|
||||
static async pauseDownload(downloadKey = this.downloadingGameId) {
|
||||
await PythonRPC.rpc
|
||||
.post("/action", {
|
||||
action: "pause",
|
||||
game_id: this.downloadingGameId,
|
||||
game_id: downloadKey,
|
||||
} as PauseDownloadPayload)
|
||||
.catch(() => {});
|
||||
|
||||
|
||||
@@ -190,12 +190,12 @@ export const watchProcesses = async () => {
|
||||
const hasProcess = processMap.get(executable)?.has(executablePath);
|
||||
|
||||
if (hasProcess) {
|
||||
if (gamesPlaytime.has(`${game.shop}-${game.objectId}`)) {
|
||||
if (gamesPlaytime.has(levelKeys.game(game.shop, game.objectId))) {
|
||||
onTickGame(game);
|
||||
} else {
|
||||
onOpenGame(game);
|
||||
}
|
||||
} else if (gamesPlaytime.has(`${game.shop}-${game.objectId}`)) {
|
||||
} else if (gamesPlaytime.has(levelKeys.game(game.shop, game.objectId))) {
|
||||
onCloseGame(game);
|
||||
}
|
||||
}
|
||||
@@ -207,20 +207,17 @@ export const watchProcesses = async () => {
|
||||
return {
|
||||
id: entry[0],
|
||||
sessionDurationInMillis: performance.now() - entry[1].firstTick,
|
||||
};
|
||||
} as Pick<GameRunning, "id" | "sessionDurationInMillis">;
|
||||
});
|
||||
|
||||
WindowManager.mainWindow.webContents.send(
|
||||
"on-games-running",
|
||||
gamesRunning as Pick<GameRunning, "id" | "sessionDurationInMillis">[]
|
||||
);
|
||||
WindowManager.mainWindow.webContents.send("on-games-running", gamesRunning);
|
||||
}
|
||||
};
|
||||
|
||||
function onOpenGame(game: Game) {
|
||||
const now = performance.now();
|
||||
|
||||
gamesPlaytime.set(`${game.shop}-${game.objectId}`, {
|
||||
gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
|
||||
lastTick: now,
|
||||
firstTick: now,
|
||||
lastSyncTick: now,
|
||||
@@ -235,7 +232,9 @@ function onOpenGame(game: Game) {
|
||||
|
||||
function onTickGame(game: Game) {
|
||||
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;
|
||||
|
||||
@@ -251,7 +250,7 @@ function onTickGame(game: Game) {
|
||||
lastTimePlayed: new Date(),
|
||||
});
|
||||
|
||||
gamesPlaytime.set(`${game.shop}-${game.objectId}`, {
|
||||
gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
|
||||
...gamePlaytime,
|
||||
lastTick: now,
|
||||
});
|
||||
@@ -267,7 +266,7 @@ function onTickGame(game: Game) {
|
||||
|
||||
gamePromise
|
||||
.then(() => {
|
||||
gamesPlaytime.set(`${game.shop}-${game.objectId}`, {
|
||||
gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
|
||||
...gamePlaytime,
|
||||
lastSyncTick: now,
|
||||
});
|
||||
@@ -277,8 +276,10 @@ function onTickGame(game: Game) {
|
||||
}
|
||||
|
||||
const onCloseGame = (game: Game) => {
|
||||
const gamePlaytime = gamesPlaytime.get(`${game.shop}-${game.objectId}`)!;
|
||||
gamesPlaytime.delete(`${game.shop}-${game.objectId}`);
|
||||
const gamePlaytime = gamesPlaytime.get(
|
||||
levelKeys.game(game.shop, game.objectId)
|
||||
)!;
|
||||
gamesPlaytime.delete(levelKeys.game(game.shop, game.objectId));
|
||||
|
||||
if (game.remoteId) {
|
||||
updateGamePlaytime(
|
||||
|
||||
Reference in New Issue
Block a user