mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-24 11:21:02 +00:00
feat: separate game assets from game stats
This commit is contained in:
@@ -142,29 +142,23 @@ export function GameDetailsContextProvider({
|
||||
}
|
||||
});
|
||||
|
||||
const statsPromise = window.electron
|
||||
.getGameStats(objectId, shop)
|
||||
.then((result) => {
|
||||
if (abortController.signal.aborted) return null;
|
||||
setStats(result);
|
||||
return result;
|
||||
});
|
||||
window.electron.getGameStats(objectId, shop).then((result) => {
|
||||
if (abortController.signal.aborted) return;
|
||||
setStats(result);
|
||||
});
|
||||
|
||||
Promise.all([shopDetailsPromise, statsPromise])
|
||||
.then(([_, stats]) => {
|
||||
if (stats) {
|
||||
const assets = stats.assets;
|
||||
if (assets) {
|
||||
window.electron.saveGameShopAssets(objectId, shop, assets);
|
||||
const assetsPromise = window.electron.getGameAssets(objectId, shop);
|
||||
|
||||
setShopDetails((prev) => {
|
||||
if (!prev) return null;
|
||||
return {
|
||||
...prev,
|
||||
assets,
|
||||
};
|
||||
});
|
||||
}
|
||||
Promise.all([shopDetailsPromise, assetsPromise])
|
||||
.then(([_, assets]) => {
|
||||
if (assets) {
|
||||
setShopDetails((prev) => {
|
||||
if (!prev) return null;
|
||||
return {
|
||||
...prev,
|
||||
assets,
|
||||
};
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -207,8 +201,8 @@ export function GameDetailsContextProvider({
|
||||
setShowRepacksModal(true);
|
||||
try {
|
||||
window.history.replaceState({}, document.title, location.pathname);
|
||||
} catch (_e) {
|
||||
void _e;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
10
src/renderer/src/declaration.d.ts
vendored
10
src/renderer/src/declaration.d.ts
vendored
@@ -39,6 +39,7 @@ import type {
|
||||
AchievementCustomNotificationPosition,
|
||||
AchievementNotificationInfo,
|
||||
UserLibraryResponse,
|
||||
Game,
|
||||
} from "@types";
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import type disk from "diskusage";
|
||||
@@ -77,11 +78,6 @@ declare global {
|
||||
skip: number
|
||||
) => Promise<{ edges: CatalogueSearchResult[]; count: number }>;
|
||||
getCatalogue: (category: CatalogueCategory) => Promise<ShopAssets[]>;
|
||||
saveGameShopAssets: (
|
||||
objectId: string,
|
||||
shop: GameShop,
|
||||
assets: ShopAssets
|
||||
) => Promise<void>;
|
||||
getGameShopDetails: (
|
||||
objectId: string,
|
||||
shop: GameShop,
|
||||
@@ -93,6 +89,10 @@ declare global {
|
||||
shop: GameShop
|
||||
) => Promise<HowLongToBeatCategory[] | null>;
|
||||
getGameStats: (objectId: string, shop: GameShop) => Promise<GameStats>;
|
||||
getGameAssets: (
|
||||
objectId: string,
|
||||
shop: GameShop
|
||||
) => Promise<ShopAssets | null>;
|
||||
getTrendingGames: () => Promise<TrendingGame[]>;
|
||||
createGameReview: (
|
||||
shop: GameShop,
|
||||
|
||||
@@ -233,9 +233,18 @@ export function Sidebar() {
|
||||
{t("rating_count")}
|
||||
</p>
|
||||
<StarRating
|
||||
rating={stats?.averageScore === 0 ? null : stats?.averageScore ?? null}
|
||||
rating={
|
||||
stats?.averageScore === 0
|
||||
? null
|
||||
: (stats?.averageScore ?? null)
|
||||
}
|
||||
size={16}
|
||||
showCalculating={!!(stats && (stats.averageScore === null || stats.averageScore === 0))}
|
||||
showCalculating={
|
||||
!!(
|
||||
stats &&
|
||||
(stats.averageScore === null || stats.averageScore === 0)
|
||||
)
|
||||
}
|
||||
calculatingText={t("calculating", { ns: "game_card" })}
|
||||
hideIcon={true}
|
||||
/>
|
||||
|
||||
@@ -234,7 +234,7 @@ export function UserLibraryGameCard({
|
||||
</div>
|
||||
|
||||
<img
|
||||
src={game.coverImageUrl}
|
||||
src={game.coverImageUrl ?? undefined}
|
||||
alt={game.title}
|
||||
className="user-library-game__game-image"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user