mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
Merge branch 'main' into main
This commit is contained in:
@@ -20,6 +20,7 @@ import "./library/create-game-shortcut";
|
||||
import "./library/close-game";
|
||||
import "./library/delete-game-folder";
|
||||
import "./library/get-game-by-object-id";
|
||||
import "./library/sync-game-by-object-id";
|
||||
import "./library/get-library";
|
||||
import "./library/extract-game-download";
|
||||
import "./library/open-game";
|
||||
|
||||
28
src/main/events/library/sync-game-by-object-id.ts
Normal file
28
src/main/events/library/sync-game-by-object-id.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import { HydraApi } from "@main/services";
|
||||
import type { GameShop, UserGameDetails } from "@types";
|
||||
|
||||
const syncGameByObjectId = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
return HydraApi.get<UserGameDetails>(
|
||||
`/profile/games/${shop}/${objectId}`
|
||||
).then(async (res) => {
|
||||
const { id, playTimeInSeconds, ...rest } = res;
|
||||
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...rest,
|
||||
remoteId: id,
|
||||
playTimeInMilliseconds: playTimeInSeconds * 1000,
|
||||
});
|
||||
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
registerEvent("syncGameByObjectId", syncGameByObjectId);
|
||||
@@ -187,6 +187,8 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
ipcRenderer.invoke("deleteGameFolder", shop, objectId),
|
||||
getGameByObjectId: (shop: GameShop, objectId: string) =>
|
||||
ipcRenderer.invoke("getGameByObjectId", shop, objectId),
|
||||
syncGameByObjectId: (shop: GameShop, objectId: string) =>
|
||||
ipcRenderer.invoke("syncGameByObjectId", shop, objectId),
|
||||
resetGameAchievements: (shop: GameShop, objectId: string) =>
|
||||
ipcRenderer.invoke("resetGameAchievements", shop, objectId),
|
||||
extractGameDownload: (shop: GameShop, objectId: string) =>
|
||||
|
||||
@@ -108,7 +108,7 @@ export function GameDetailsContextProvider({
|
||||
return window.electron
|
||||
.getGameByObjectId(shop, objectId)
|
||||
.then((result) => setGame(result));
|
||||
}, [setGame, shop, objectId]);
|
||||
}, [shop, objectId]);
|
||||
|
||||
const isGameDownloading =
|
||||
lastPacket?.gameId === game?.id && game?.download?.status === "active";
|
||||
@@ -183,11 +183,13 @@ export function GameDetailsContextProvider({
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
updateGame();
|
||||
window.electron.syncGameByObjectId(shop, objectId).then(() => {
|
||||
if (abortController.signal.aborted) return;
|
||||
updateGame();
|
||||
});
|
||||
}, [
|
||||
updateGame,
|
||||
dispatch,
|
||||
gameTitle,
|
||||
objectId,
|
||||
shop,
|
||||
i18n.language,
|
||||
|
||||
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
@@ -155,6 +155,7 @@ declare global {
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => Promise<LibraryGame | null>;
|
||||
syncGameByObjectId: (shop: GameShop, objectId: string) => Promise<void>;
|
||||
onGamesRunning: (
|
||||
cb: (
|
||||
gamesRunning: Pick<GameRunning, "id" | "sessionDurationInMillis">[]
|
||||
|
||||
@@ -77,6 +77,9 @@ export default function Catalogue() {
|
||||
}, 500)
|
||||
).current;
|
||||
|
||||
const decodeHTML = (s: string) =>
|
||||
s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||
|
||||
useEffect(() => {
|
||||
setResults([]);
|
||||
setIsLoading(true);
|
||||
@@ -165,7 +168,7 @@ export default function Catalogue() {
|
||||
})),
|
||||
|
||||
...filters.publishers.map((publisher) => ({
|
||||
label: publisher,
|
||||
label: decodeHTML(publisher),
|
||||
orbColor: filterCategoryColors.publishers,
|
||||
key: "publishers",
|
||||
value: publisher,
|
||||
@@ -208,7 +211,7 @@ export default function Catalogue() {
|
||||
{
|
||||
title: t("publishers"),
|
||||
items: steamPublishers.map((publisher) => ({
|
||||
label: publisher,
|
||||
label: decodeHTML(publisher),
|
||||
value: publisher,
|
||||
checked: filters.publishers.includes(publisher),
|
||||
})),
|
||||
|
||||
@@ -343,6 +343,23 @@ export type LibraryGame = Game &
|
||||
download: Download | null;
|
||||
};
|
||||
|
||||
export type UserGameDetails = ShopAssets & {
|
||||
id: string;
|
||||
playTimeInSeconds: number;
|
||||
unlockedAchievementCount: number;
|
||||
achievementsPointsEarnedSum: number;
|
||||
lastTimePlayed: Date | null;
|
||||
isDeleted: boolean;
|
||||
isFavorite: boolean;
|
||||
friendsWhoPlayed: {
|
||||
id: string;
|
||||
displayName: string;
|
||||
profileImageUrl: string | null;
|
||||
lastTimePlayed: Date | null;
|
||||
playTimeInSeconds: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export * from "./game.types";
|
||||
export * from "./steam.types";
|
||||
export * from "./download.types";
|
||||
|
||||
Reference in New Issue
Block a user